mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 21:39:35 -04:00
taskstats: fold the two cpumask handlers into one
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. Link: https://lore.kernel.org/20260728202104.17839-3-include@grrlz.net Signed-off-by: Bradley Morgan <include@grrlz.net> Cc: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
36ffbe1d5e
commit
c4904c4ae3
@@ -448,36 +448,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)
|
||||
@@ -552,9 +534,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])
|
||||
|
||||
Reference in New Issue
Block a user