From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,bsingharora@gmail.com,balbirs@nvidia.com,akpm@linux-foundation.org,include@grrlz.net,akpm@linux-foundation.org
Subject: + taskstats-fold-the-two-pid-tgid-handlers-into-one.patch added to mm-nonmm-unstable branch
Date: Mon, 31 Aug 2026 21:49:22 -0700 [thread overview]
Message-ID: <20260901044922.ACA941F000E9@smtp.kernel.org> (raw)
The patch titled
Subject: taskstats: fold the two pid/tgid handlers into one
has been added to the -mm mm-nonmm-unstable branch. Its filename is
taskstats-fold-the-two-pid-tgid-handlers-into-one.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/taskstats-fold-the-two-pid-tgid-handlers-into-one.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Bradley Morgan <include@grrlz.net>
Subject: taskstats: fold the two pid/tgid handlers into one
Date: Sat, 1 Aug 2026 22:58:44 +0000
cmd_attr_pid() and cmd_attr_tgid() are copy paste. fold them into one
handler that takes the attr type and fill function as parameters, same
pattern as the cpumask fold in 59c0bc949c5e.
No functional change.
Link: https://lore.kernel.org/20260801225845.23855-1-include@grrlz.net
Signed-off-by: Bradley Morgan <include@grrlz.net>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Balbir Singh <balbirs@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
kernel/taskstats.c | 47 ++++++++++---------------------------------
1 file changed, 12 insertions(+), 35 deletions(-)
--- a/kernel/taskstats.c~taskstats-fold-the-two-pid-tgid-handlers-into-one
+++ a/kernel/taskstats.c
@@ -473,7 +473,8 @@ static size_t taskstats_packet_size(void
return size;
}
-static int cmd_attr_pid(struct genl_info *info)
+static int cmd_attr_pid_tgid(struct genl_info *info, int attr,
+ int (*fill)(pid_t, struct taskstats *))
{
struct taskstats *stats;
struct sk_buff *rep_skb;
@@ -488,41 +489,15 @@ static int cmd_attr_pid(struct genl_info
return rc;
rc = -EINVAL;
- pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]);
- stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, pid);
+ pid = nla_get_u32(info->attrs[attr]);
+ stats = mk_reply(rep_skb,
+ attr == TASKSTATS_CMD_ATTR_PID
+ ? TASKSTATS_TYPE_PID : TASKSTATS_TYPE_TGID,
+ pid);
if (!stats)
goto err;
- rc = fill_stats_for_pid(pid, stats);
- if (rc < 0)
- goto err;
- return send_reply(rep_skb, info);
-err:
- nlmsg_free(rep_skb);
- return rc;
-}
-
-static int cmd_attr_tgid(struct genl_info *info)
-{
- struct taskstats *stats;
- struct sk_buff *rep_skb;
- size_t size;
- u32 tgid;
- int rc;
-
- size = taskstats_packet_size();
-
- rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, size);
- if (rc < 0)
- return rc;
-
- rc = -EINVAL;
- tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]);
- stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tgid);
- if (!stats)
- goto err;
-
- rc = fill_stats_for_tgid(tgid, stats);
+ rc = fill(pid, stats);
if (rc < 0)
goto err;
return send_reply(rep_skb, info);
@@ -542,9 +517,11 @@ static int taskstats_user_cmd(struct sk_
TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK,
DEREGISTER);
else if (info->attrs[TASKSTATS_CMD_ATTR_PID])
- return cmd_attr_pid(info);
+ return cmd_attr_pid_tgid(info, TASKSTATS_CMD_ATTR_PID,
+ fill_stats_for_pid);
else if (info->attrs[TASKSTATS_CMD_ATTR_TGID])
- return cmd_attr_tgid(info);
+ return cmd_attr_pid_tgid(info, TASKSTATS_CMD_ATTR_TGID,
+ fill_stats_for_tgid);
else
return -EINVAL;
}
_
Patches currently in -mm which might be from include@grrlz.net are
taskstats-fold-the-two-pid-tgid-handlers-into-one.patch
reply other threads:[~2026-09-01 4:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260901044922.ACA941F000E9@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=balbirs@nvidia.com \
--cc=bsingharora@gmail.com \
--cc=include@grrlz.net \
--cc=mm-commits@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.