[PATCH 4/4] padata: remove cpumask change notifier

From: Daniel Jordan
Date: Wed Nov 20 2019 - 13:58:56 EST


Since commit 63d3578892dc ("crypto: pcrypt - remove padata cpumask
notifier") this feature is unused and may deliver unexpected data with
the introduction of struct padata_shell (a notification mask that
includes -ENOMEM), so get rid of it.

Signed-off-by: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx>
Cc: Eric Biggers <ebiggers@xxxxxxxxxx>
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Cc: Jonathan Corbet <corbet@xxxxxxx>
Cc: Steffen Klassert <steffen.klassert@xxxxxxxxxxx>
Cc: linux-crypto@xxxxxxxxxxxxxxx
Cc: linux-doc@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
Documentation/padata.txt | 24 ------------------
crypto/pcrypt.c | 1 -
include/linux/padata.h | 10 --------
kernel/padata.c | 53 +++-------------------------------------
4 files changed, 3 insertions(+), 85 deletions(-)

diff --git a/Documentation/padata.txt b/Documentation/padata.txt
index a03afb1588f9..82e42dbaab65 100644
--- a/Documentation/padata.txt
+++ b/Documentation/padata.txt
@@ -74,30 +74,6 @@ padata_set_cpumask is used to change just one of the cpumasks. Here cpumask_type
is one of PADATA_CPU_SERIAL or PADATA_CPU_PARALLEL, and cpumask specifies the
new cpumask to use.

-If a user is interested in padata cpumask changes, he can register to
-the padata cpumask change notifier::
-
- int padata_register_cpumask_notifier(struct padata_instance *pinst,
- struct notifier_block *nblock);
-
-To unregister from that notifier::
-
- int padata_unregister_cpumask_notifier(struct padata_instance *pinst,
- struct notifier_block *nblock);
-
-The padata cpumask change notifier notifies about changes of the usable
-cpumasks, i.e. the subset of active CPUs in the user supplied cpumask.
-
-Padata calls the notifier chain with::
-
- blocking_notifier_call_chain(&pinst->cpumask_change_notifier,
- notification_mask,
- &pd_new->cpumask);
-
-Here cpumask_change_notifier is registered notifier, notification_mask
-is one of PADATA_CPU_SERIAL, PADATA_CPU_PARALLEL and cpumask is a pointer
-to a struct padata_cpumask that contains the new cpumask information.
-
Actually submitting work to the padata instance requires the creation of a
padata_priv structure::

diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
index 3e026e7a7e75..af60016d25c4 100644
--- a/crypto/pcrypt.c
+++ b/crypto/pcrypt.c
@@ -13,7 +13,6 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
-#include <linux/notifier.h>
#include <linux/kobject.h>
#include <linux/cpu.h>
#include <crypto/pcrypt.h>
diff --git a/include/linux/padata.h b/include/linux/padata.h
index 9e0be23bd9ff..efdd0b129c53 100644
--- a/include/linux/padata.h
+++ b/include/linux/padata.h
@@ -13,7 +13,6 @@
#include <linux/workqueue.h>
#include <linux/spinlock.h>
#include <linux/list.h>
-#include <linux/notifier.h>
#include <linux/kobject.h>

#define PADATA_CPU_SERIAL 0x01
@@ -141,14 +140,10 @@ struct padata_shell {
/**
* struct padata_instance - The overall control structure.
*
- * @cpu_notifier: cpu hotplug notifier.
* @parallel_wq: The workqueue used for parallel work.
* @serial_wq: The workqueue used for serial work.
* @pslist: List of padata_shell objects attached to this instance.
* @cpumask: User supplied cpumasks for parallel and serial works.
- * @cpumask_change_notifier: Notifiers chain for user-defined notify
- * callbacks that will be called when either @pcpu or @cbcpu
- * or both cpumasks change.
* @kobj: padata instance kernel object.
* @lock: padata instance lock.
* @flags: padata flags.
@@ -159,7 +154,6 @@ struct padata_instance {
struct workqueue_struct *serial_wq;
struct list_head pslist;
struct padata_cpumask cpumask;
- struct blocking_notifier_head cpumask_change_notifier;
struct kobject kobj;
struct mutex lock;
u8 flags;
@@ -179,8 +173,4 @@ extern int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type,
cpumask_var_t cpumask);
extern int padata_start(struct padata_instance *pinst);
extern void padata_stop(struct padata_instance *pinst);
-extern int padata_register_cpumask_notifier(struct padata_instance *pinst,
- struct notifier_block *nblock);
-extern int padata_unregister_cpumask_notifier(struct padata_instance *pinst,
- struct notifier_block *nblock);
#endif
diff --git a/kernel/padata.c b/kernel/padata.c
index cd9ae6822460..7305e81b9bee 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -492,81 +492,35 @@ static void __padata_stop(struct padata_instance *pinst)
}

/* Replace the internal control structure with a new one. */
-static int padata_replace_one(struct padata_shell *ps)
+static void padata_replace_one(struct padata_shell *ps)
{
struct parallel_data *pd_old = rcu_dereference_protected(ps->pd, 1);
struct parallel_data *pd_new;
- int notification_mask = 0;

pd_new = padata_alloc_pd(ps);
if (!pd_new)
- return -ENOMEM;
+ return;

rcu_assign_pointer(ps->pd, pd_new);

- if (!cpumask_equal(pd_old->cpumask.pcpu, pd_new->cpumask.pcpu))
- notification_mask |= PADATA_CPU_PARALLEL;
- if (!cpumask_equal(pd_old->cpumask.cbcpu, pd_new->cpumask.cbcpu))
- notification_mask |= PADATA_CPU_SERIAL;
-
if (atomic_dec_and_test(&pd_old->refcnt))
padata_free_pd(pd_old);
-
- return notification_mask;
}

static void padata_replace(struct padata_instance *pinst)
{
- int notification_mask = 0;
struct padata_shell *ps;

pinst->flags |= PADATA_RESET;

list_for_each_entry(ps, &pinst->pslist, list)
- notification_mask |= padata_replace_one(ps);
+ padata_replace_one(ps);

synchronize_rcu();

- if (notification_mask)
- blocking_notifier_call_chain(&pinst->cpumask_change_notifier,
- notification_mask,
- &pinst->cpumask);
-
pinst->flags &= ~PADATA_RESET;
}

-/**
- * padata_register_cpumask_notifier - Registers a notifier that will be called
- * if either pcpu or cbcpu or both cpumasks change.
- *
- * @pinst: A poineter to padata instance
- * @nblock: A pointer to notifier block.
- */
-int padata_register_cpumask_notifier(struct padata_instance *pinst,
- struct notifier_block *nblock)
-{
- return blocking_notifier_chain_register(&pinst->cpumask_change_notifier,
- nblock);
-}
-EXPORT_SYMBOL(padata_register_cpumask_notifier);
-
-/**
- * padata_unregister_cpumask_notifier - Unregisters cpumask notifier
- * registered earlier using padata_register_cpumask_notifier
- *
- * @pinst: A pointer to data instance.
- * @nlock: A pointer to notifier block.
- */
-int padata_unregister_cpumask_notifier(struct padata_instance *pinst,
- struct notifier_block *nblock)
-{
- return blocking_notifier_chain_unregister(
- &pinst->cpumask_change_notifier,
- nblock);
-}
-EXPORT_SYMBOL(padata_unregister_cpumask_notifier);
-
-
/* If cpumask contains no active cpu, we mark the instance as invalid. */
static bool padata_validate_cpumask(struct padata_instance *pinst,
const struct cpumask *cpumask)
@@ -944,7 +898,6 @@ static struct padata_instance *padata_alloc(const char *name,

pinst->flags = 0;

- BLOCKING_INIT_NOTIFIER_HEAD(&pinst->cpumask_change_notifier);
kobject_init(&pinst->kobj, &padata_attr_type);
mutex_init(&pinst->lock);

--
2.23.0