mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 08:38:45 +02:00 
			
		
		
		
	crypto: pcrypt - remove padata cpumask notifier
Now that padata_do_parallel takes care of finding an alternate callback CPU, there's no need for pcrypt's callback cpumask, so remove it and the notifier callback that keeps it in sync. Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Lai Jiangshan <jiangshanlai@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tejun Heo <tj@kernel.org> Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
		
							parent
							
								
									e6ce0e0807
								
							
						
					
					
						commit
						63d3578892
					
				
					 1 changed files with 18 additions and 107 deletions
				
			
		
							
								
								
									
										125
									
								
								crypto/pcrypt.c
									
									
									
									
									
								
							
							
						
						
									
										125
									
								
								crypto/pcrypt.c
									
									
									
									
									
								
							|  | @ -18,33 +18,8 @@ | ||||||
| #include <linux/cpu.h> | #include <linux/cpu.h> | ||||||
| #include <crypto/pcrypt.h> | #include <crypto/pcrypt.h> | ||||||
| 
 | 
 | ||||||
| struct padata_pcrypt { | static struct padata_instance *pencrypt; | ||||||
| 	struct padata_instance *pinst; | static struct padata_instance *pdecrypt; | ||||||
| 
 |  | ||||||
| 	/*
 |  | ||||||
| 	 * Cpumask for callback CPUs. It should be |  | ||||||
| 	 * equal to serial cpumask of corresponding padata instance, |  | ||||||
| 	 * so it is updated when padata notifies us about serial |  | ||||||
| 	 * cpumask change. |  | ||||||
| 	 * |  | ||||||
| 	 * cb_cpumask is protected by RCU. This fact prevents us from |  | ||||||
| 	 * using cpumask_var_t directly because the actual type of |  | ||||||
| 	 * cpumsak_var_t depends on kernel configuration(particularly on |  | ||||||
| 	 * CONFIG_CPUMASK_OFFSTACK macro). Depending on the configuration |  | ||||||
| 	 * cpumask_var_t may be either a pointer to the struct cpumask |  | ||||||
| 	 * or a variable allocated on the stack. Thus we can not safely use |  | ||||||
| 	 * cpumask_var_t with RCU operations such as rcu_assign_pointer or |  | ||||||
| 	 * rcu_dereference. So cpumask_var_t is wrapped with struct |  | ||||||
| 	 * pcrypt_cpumask which makes possible to use it with RCU. |  | ||||||
| 	 */ |  | ||||||
| 	struct pcrypt_cpumask { |  | ||||||
| 		cpumask_var_t mask; |  | ||||||
| 	} *cb_cpumask; |  | ||||||
| 	struct notifier_block nblock; |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| static struct padata_pcrypt pencrypt; |  | ||||||
| static struct padata_pcrypt pdecrypt; |  | ||||||
| static struct kset           *pcrypt_kset; | static struct kset           *pcrypt_kset; | ||||||
| 
 | 
 | ||||||
| struct pcrypt_instance_ctx { | struct pcrypt_instance_ctx { | ||||||
|  | @ -128,7 +103,7 @@ static int pcrypt_aead_encrypt(struct aead_request *req) | ||||||
| 			       req->cryptlen, req->iv); | 			       req->cryptlen, req->iv); | ||||||
| 	aead_request_set_ad(creq, req->assoclen); | 	aead_request_set_ad(creq, req->assoclen); | ||||||
| 
 | 
 | ||||||
| 	err = padata_do_parallel(pencrypt.pinst, padata, &ctx->cb_cpu); | 	err = padata_do_parallel(pencrypt, padata, &ctx->cb_cpu); | ||||||
| 	if (!err) | 	if (!err) | ||||||
| 		return -EINPROGRESS; | 		return -EINPROGRESS; | ||||||
| 
 | 
 | ||||||
|  | @ -170,7 +145,7 @@ static int pcrypt_aead_decrypt(struct aead_request *req) | ||||||
| 			       req->cryptlen, req->iv); | 			       req->cryptlen, req->iv); | ||||||
| 	aead_request_set_ad(creq, req->assoclen); | 	aead_request_set_ad(creq, req->assoclen); | ||||||
| 
 | 
 | ||||||
| 	err = padata_do_parallel(pdecrypt.pinst, padata, &ctx->cb_cpu); | 	err = padata_do_parallel(pdecrypt, padata, &ctx->cb_cpu); | ||||||
| 	if (!err) | 	if (!err) | ||||||
| 		return -EINPROGRESS; | 		return -EINPROGRESS; | ||||||
| 
 | 
 | ||||||
|  | @ -317,36 +292,6 @@ static int pcrypt_create(struct crypto_template *tmpl, struct rtattr **tb) | ||||||
| 	return -EINVAL; | 	return -EINVAL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int pcrypt_cpumask_change_notify(struct notifier_block *self, |  | ||||||
| 					unsigned long val, void *data) |  | ||||||
| { |  | ||||||
| 	struct padata_pcrypt *pcrypt; |  | ||||||
| 	struct pcrypt_cpumask *new_mask, *old_mask; |  | ||||||
| 	struct padata_cpumask *cpumask = (struct padata_cpumask *)data; |  | ||||||
| 
 |  | ||||||
| 	if (!(val & PADATA_CPU_SERIAL)) |  | ||||||
| 		return 0; |  | ||||||
| 
 |  | ||||||
| 	pcrypt = container_of(self, struct padata_pcrypt, nblock); |  | ||||||
| 	new_mask = kmalloc(sizeof(*new_mask), GFP_KERNEL); |  | ||||||
| 	if (!new_mask) |  | ||||||
| 		return -ENOMEM; |  | ||||||
| 	if (!alloc_cpumask_var(&new_mask->mask, GFP_KERNEL)) { |  | ||||||
| 		kfree(new_mask); |  | ||||||
| 		return -ENOMEM; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	old_mask = pcrypt->cb_cpumask; |  | ||||||
| 
 |  | ||||||
| 	cpumask_copy(new_mask->mask, cpumask->cbcpu); |  | ||||||
| 	rcu_assign_pointer(pcrypt->cb_cpumask, new_mask); |  | ||||||
| 	synchronize_rcu(); |  | ||||||
| 
 |  | ||||||
| 	free_cpumask_var(old_mask->mask); |  | ||||||
| 	kfree(old_mask); |  | ||||||
| 	return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name) | static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name) | ||||||
| { | { | ||||||
| 	int ret; | 	int ret; | ||||||
|  | @ -359,63 +304,29 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name) | ||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int pcrypt_init_padata(struct padata_pcrypt *pcrypt, | static int pcrypt_init_padata(struct padata_instance **pinst, const char *name) | ||||||
| 			      const char *name) |  | ||||||
| { | { | ||||||
| 	int ret = -ENOMEM; | 	int ret = -ENOMEM; | ||||||
| 	struct pcrypt_cpumask *mask; |  | ||||||
| 
 | 
 | ||||||
| 	get_online_cpus(); | 	get_online_cpus(); | ||||||
| 
 | 
 | ||||||
| 	pcrypt->pinst = padata_alloc_possible(name); | 	*pinst = padata_alloc_possible(name); | ||||||
| 	if (!pcrypt->pinst) | 	if (!*pinst) | ||||||
| 		goto err; | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	mask = kmalloc(sizeof(*mask), GFP_KERNEL); | 	ret = pcrypt_sysfs_add(*pinst, name); | ||||||
| 	if (!mask) |  | ||||||
| 		goto err_free_padata; |  | ||||||
| 	if (!alloc_cpumask_var(&mask->mask, GFP_KERNEL)) { |  | ||||||
| 		kfree(mask); |  | ||||||
| 		goto err_free_padata; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	cpumask_and(mask->mask, cpu_possible_mask, cpu_online_mask); |  | ||||||
| 	rcu_assign_pointer(pcrypt->cb_cpumask, mask); |  | ||||||
| 
 |  | ||||||
| 	pcrypt->nblock.notifier_call = pcrypt_cpumask_change_notify; |  | ||||||
| 	ret = padata_register_cpumask_notifier(pcrypt->pinst, &pcrypt->nblock); |  | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		goto err_free_cpumask; | 		padata_free(*pinst); | ||||||
| 
 | 
 | ||||||
| 	ret = pcrypt_sysfs_add(pcrypt->pinst, name); |  | ||||||
| 	if (ret) |  | ||||||
| 		goto err_unregister_notifier; |  | ||||||
| 
 |  | ||||||
| 	put_online_cpus(); |  | ||||||
| 
 |  | ||||||
| 	return ret; |  | ||||||
| 
 |  | ||||||
| err_unregister_notifier: |  | ||||||
| 	padata_unregister_cpumask_notifier(pcrypt->pinst, &pcrypt->nblock); |  | ||||||
| err_free_cpumask: |  | ||||||
| 	free_cpumask_var(mask->mask); |  | ||||||
| 	kfree(mask); |  | ||||||
| err_free_padata: |  | ||||||
| 	padata_free(pcrypt->pinst); |  | ||||||
| err: |  | ||||||
| 	put_online_cpus(); | 	put_online_cpus(); | ||||||
| 
 | 
 | ||||||
| 	return ret; | 	return ret; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void pcrypt_fini_padata(struct padata_pcrypt *pcrypt) | static void pcrypt_fini_padata(struct padata_instance *pinst) | ||||||
| { | { | ||||||
| 	free_cpumask_var(pcrypt->cb_cpumask->mask); | 	padata_stop(pinst); | ||||||
| 	kfree(pcrypt->cb_cpumask); | 	padata_free(pinst); | ||||||
| 
 |  | ||||||
| 	padata_stop(pcrypt->pinst); |  | ||||||
| 	padata_unregister_cpumask_notifier(pcrypt->pinst, &pcrypt->nblock); |  | ||||||
| 	padata_free(pcrypt->pinst); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static struct crypto_template pcrypt_tmpl = { | static struct crypto_template pcrypt_tmpl = { | ||||||
|  | @ -440,13 +351,13 @@ static int __init pcrypt_init(void) | ||||||
| 	if (err) | 	if (err) | ||||||
| 		goto err_deinit_pencrypt; | 		goto err_deinit_pencrypt; | ||||||
| 
 | 
 | ||||||
| 	padata_start(pencrypt.pinst); | 	padata_start(pencrypt); | ||||||
| 	padata_start(pdecrypt.pinst); | 	padata_start(pdecrypt); | ||||||
| 
 | 
 | ||||||
| 	return crypto_register_template(&pcrypt_tmpl); | 	return crypto_register_template(&pcrypt_tmpl); | ||||||
| 
 | 
 | ||||||
| err_deinit_pencrypt: | err_deinit_pencrypt: | ||||||
| 	pcrypt_fini_padata(&pencrypt); | 	pcrypt_fini_padata(pencrypt); | ||||||
| err_unreg_kset: | err_unreg_kset: | ||||||
| 	kset_unregister(pcrypt_kset); | 	kset_unregister(pcrypt_kset); | ||||||
| err: | err: | ||||||
|  | @ -455,8 +366,8 @@ static int __init pcrypt_init(void) | ||||||
| 
 | 
 | ||||||
| static void __exit pcrypt_exit(void) | static void __exit pcrypt_exit(void) | ||||||
| { | { | ||||||
| 	pcrypt_fini_padata(&pencrypt); | 	pcrypt_fini_padata(pencrypt); | ||||||
| 	pcrypt_fini_padata(&pdecrypt); | 	pcrypt_fini_padata(pdecrypt); | ||||||
| 
 | 
 | ||||||
| 	kset_unregister(pcrypt_kset); | 	kset_unregister(pcrypt_kset); | ||||||
| 	crypto_unregister_template(&pcrypt_tmpl); | 	crypto_unregister_template(&pcrypt_tmpl); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Daniel Jordan
						Daniel Jordan