* [PATCH 0/2] taskstats: tidy up the cpumask command path @ 2026-07-28 20:21 Bradley Morgan 2026-07-28 20:21 ` [PATCH 1/2] taskstats: drop the dead NULL attribute check in parse() Bradley Morgan 2026-07-28 20:21 ` [PATCH 2/2] taskstats: fold the two cpumask handlers into one Bradley Morgan 0 siblings, 2 replies; 3+ messages in thread From: Bradley Morgan @ 2026-07-28 20:21 UTC (permalink / raw) To: Balbir Singh, Andrew Morton; +Cc: linux-kernel, Bradley Morgan Two small cleanups from reading kernel/taskstats.c. No functional change in either one. Patch 1 removes an unreachable NULL attribute check in parse(). Its stray "return 1" is not an error to any caller, so had the path ever been reached it would have registered listeners against an uninitialized cpumask. Patch 2 folds cmd_attr_register_cpumask() and cmd_attr_deregister_cpumask() together, since they only differed in one attribute and one action. Bradley Morgan (2): taskstats: drop the dead NULL attribute check in parse() taskstats: fold the two cpumask handlers into one kernel/taskstats.c | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) -- 2.47.3 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] taskstats: drop the dead NULL attribute check in parse() 2026-07-28 20:21 [PATCH 0/2] taskstats: tidy up the cpumask command path Bradley Morgan @ 2026-07-28 20:21 ` Bradley Morgan 2026-07-28 20:21 ` [PATCH 2/2] taskstats: fold the two cpumask handlers into one Bradley Morgan 1 sibling, 0 replies; 3+ messages in thread From: Bradley Morgan @ 2026-07-28 20:21 UTC (permalink / raw) To: Balbir Singh, Andrew Morton; +Cc: linux-kernel, Bradley Morgan taskstats_user_cmd() only calls the cpumask handlers after checking the same info->attrs[] entry, so parse() never sees a NULL attribute. Drop the check and its odd "return 1", which no caller tested for anyway. No functional change. Signed-off-by: Bradley Morgan <include@grrlz.net> --- kernel/taskstats.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/taskstats.c b/kernel/taskstats.c index bca91c394793..e7f8e1b5d1bc 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -361,8 +361,6 @@ static int parse(struct nlattr *na, struct cpumask *mask) int len; int ret; - if (na == NULL) - return 1; len = nla_len(na); if (len > TASKSTATS_CPUMASK_MAXLEN) return -E2BIG; -- 2.47.3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] taskstats: fold the two cpumask handlers into one 2026-07-28 20:21 [PATCH 0/2] taskstats: tidy up the cpumask command path Bradley Morgan 2026-07-28 20:21 ` [PATCH 1/2] taskstats: drop the dead NULL attribute check in parse() Bradley Morgan @ 2026-07-28 20:21 ` Bradley Morgan 1 sibling, 0 replies; 3+ messages in thread From: Bradley Morgan @ 2026-07-28 20:21 UTC (permalink / raw) To: Balbir Singh, Andrew Morton; +Cc: linux-kernel, Bradley Morgan cmd_attr_register_cpumask() and cmd_attr_deregister_cpumask() differed only in which attribute they parsed and which action they passed on, so take both as arguments. __free(free_cpumask_var) then removes the goto. No functional change. Signed-off-by: Bradley Morgan <include@grrlz.net> --- kernel/taskstats.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/kernel/taskstats.c b/kernel/taskstats.c index e7f8e1b5d1bc..3ae1755ca1b5 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -449,36 +449,18 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info) return send_reply(rep_skb, info); } -static int cmd_attr_register_cpumask(struct genl_info *info) +static int cmd_attr_cpumask(struct genl_info *info, int attr, + enum actions action) { - cpumask_var_t mask; + cpumask_var_t mask __free(free_cpumask_var) = CPUMASK_VAR_NULL; int rc; if (!alloc_cpumask_var(&mask, GFP_KERNEL)) return -ENOMEM; - rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], mask); + rc = parse(info->attrs[attr], mask); if (rc < 0) - goto out; - rc = add_del_listener(info->snd_portid, mask, REGISTER); -out: - free_cpumask_var(mask); - return rc; -} - -static int cmd_attr_deregister_cpumask(struct genl_info *info) -{ - cpumask_var_t mask; - int rc; - - if (!alloc_cpumask_var(&mask, GFP_KERNEL)) - return -ENOMEM; - rc = parse(info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK], mask); - if (rc < 0) - goto out; - rc = add_del_listener(info->snd_portid, mask, DEREGISTER); -out: - free_cpumask_var(mask); - return rc; + return rc; + return add_del_listener(info->snd_portid, mask, action); } static size_t taskstats_packet_size(void) @@ -553,9 +535,13 @@ static int cmd_attr_tgid(struct genl_info *info) static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info) { if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK]) - return cmd_attr_register_cpumask(info); + return cmd_attr_cpumask(info, + TASKSTATS_CMD_ATTR_REGISTER_CPUMASK, + REGISTER); else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK]) - return cmd_attr_deregister_cpumask(info); + return cmd_attr_cpumask(info, + TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK, + DEREGISTER); else if (info->attrs[TASKSTATS_CMD_ATTR_PID]) return cmd_attr_pid(info); else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) -- 2.47.3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-28 20:21 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-28 20:21 [PATCH 0/2] taskstats: tidy up the cpumask command path Bradley Morgan 2026-07-28 20:21 ` [PATCH 1/2] taskstats: drop the dead NULL attribute check in parse() Bradley Morgan 2026-07-28 20:21 ` [PATCH 2/2] taskstats: fold the two cpumask handlers into one Bradley Morgan
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.