Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1574551 > unrolled thread

Re: [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly

Started byMartin Steigerwald <martin.steigerwald@teamix.de>
First post2017-02-06 11:50 +0100
Last post2017-02-06 19:30 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly Martin Steigerwald <martin.steigerwald@teamix.de> - 2017-02-06 11:50 +0100
    Re: [REGRESSION] Two issues that prevent process accounting  (taskstats) from working correctly Tejun Heo <tj@kernel.org> - 2017-02-06 17:30 +0100
      [PATCH] cpumask: use nr_cpumask_bits for parsing functions Tejun Heo <tj@kernel.org> - 2017-02-06 19:30 +0100

#1574551 — Re: [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly

FromMartin Steigerwald <martin.steigerwald@teamix.de>
Date2017-02-06 11:50 +0100
SubjectRe: [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly
Message-ID<t7P1U-3Pt-11@gated-at.bofh.it>
Am Montag, 19. Dezember 2016, 18:25:49 CET schrieb Peter Zijlstra:
> On Mon, Dec 19, 2016 at 01:06:00PM +0100, Martin Steigerwald wrote:
> > 2) When using the NETLINK inface, the command TASKSTATS_CMD_GET
> > consequently returns -EINVAL.
> > 
> > The code that is used by the atopacctd daemon is based on the demo code
> > 'getdelays.c' that can be found in the kernel source code tree
> > (..../linux/Documentation/accounting/getdelays.c). Also this 'getdelays'
> > program does not work any more (also -EINVAL on the same call)
> > with the newer kernels. I really spent a lot of time on this issue to
> > get the code running (there are many places in the kernel code where
> > -EINVAL for this call can be given), but I did not succeed. It is really
> > an incompatibility introduced by the kernel code.
> > It would be nice if the kernel maintainers provide a working version of
> > the getdelays program in the kernel source tree.
> > 
> > I only experience this problem on Debian8 with a 4.8 kernel (virtual
> > machine with 4 cores).
> > On CentOS7 with a 4.8 kernel it works fine (physical machine with 4
> > cores).
> > 
> > I will anyhow adapt atopacctd for this issue that it detects and logs
> > the -EINVAL and terminates.
> > The current version of atopacctd keeps running which is not useful at all.
> > 
> > 
> > I reported this as:
> > 
> > Bug 190711 - Process accounting: Using the NETLINK inface, the command
> > TASKSTATS_CMD_GET returns -EINVAL
> > 
> > https://bugzilla.kernel.org/show_bug.cgi?id=190711
> 
> Ben Hutchings reports:
> 
> "It looks like the taskstats bug was introduced by 513e3d2d11c9 as that
> means cpumask_parse() may not initialise as many bits as
> cpumask_subset() compares"

Thank you.

Okay, any conclusion out of this? Any feedback from the maintainers of this 
code?

Thank you,

[toc] | [next] | [standalone]


#1574963 — Re: [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly

FromTejun Heo <tj@kernel.org>
Date2017-02-06 17:30 +0100
SubjectRe: [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly
Message-ID<t7UkW-7hD-9@gated-at.bofh.it>
In reply to#1574551
Hello,

On Mon, Feb 06, 2017 at 11:39:04AM +0100, Martin Steigerwald wrote:
> > Ben Hutchings reports:
> > 
> > "It looks like the taskstats bug was introduced by 513e3d2d11c9 as that
> > means cpumask_parse() may not initialise as many bits as
> > cpumask_subset() compares"

I see, so that patch switched parsing and printing to always use
nr_cpu_ids but left the comparison functions to keep using
nr_cpumask_bits which may be NR_CPUS instead of nr_cpu_ids.

> Okay, any conclusion out of this? Any feedback from the maintainers of this 
> code?

We can switch back the parse functions to nr_cpumask_bits, or just get
rid of nr_cpumask_bits and use nr_cpu_ids everywhere.  The only reason
we use nr_cpumask_bits is because on small configurations the constant
NR_CPUS can be more efficient than having to read out nr_cpu_ids
variable each time.

Hmm... I'll restore the parse functions to use nr_cpumask_bits instead
for now.  The confusing part was the output results.  Input should be
okay even if we flip between nr_cpu_ids and NR_CPUS.

Thanks.

-- 
tejun

[toc] | [prev] | [next] | [standalone]


#1575045 — [PATCH] cpumask: use nr_cpumask_bits for parsing functions

FromTejun Heo <tj@kernel.org>
Date2017-02-06 19:30 +0100
Subject[PATCH] cpumask: use nr_cpumask_bits for parsing functions
Message-ID<t7Wd4-9Q-11@gated-at.bofh.it>
In reply to#1574963
513e3d2d11c9 ("cpumask: always use nr_cpu_ids in formatting and
parsing functions") converted both cpumask printing and parsing
functions to use nr_cpu_ids instead of nr_cpumask_bits.  While this
was okay for the printing functions as it just picked one of the two
output formats that we were alternating between depending on a kernel
config, doing the same for parsing wasn't okay.

nr_cpumask_bits can be either nr_cpu_ids or NR_CPUS.  We can always
use nr_cpu_ids but that is a variable while NR_CPUS is a constant, so
it can be more efficient to use NR_CPUS when we can get away with it.
Converting the printing functions to nr_cpu_ids makes sense because it
affects how the masks get presented to userspace and doesn't break
anything; however, using nr_cpu_ids for parsing functions can
incorrectly leave the higher bits uninitialized while reading in these
masks from userland.  As all testing and comparison functions use
nr_cpumask_bits which can be larger than nr_cpu_ids, the parsed
cpumasks can erroneously yield false negative results.

This made the taskstats interface incorrectly return -EINVAL even when
the inputs were correct.

Fix it by restoring the parse functions to use nr_cpumask_bits instead
of nr_cpu_ids.

Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 513e3d2d11c9 ("cpumask: always use nr_cpu_ids in formatting and parsing functions")
Cc: stable@vger.kernel.org # v4.0+
Reported-by: Martin Steigerwald <martin.steigerwald@teamix.de>
Debugged-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
---
 include/linux/cpumask.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index c717f5e..b3d2c1a 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -560,7 +560,7 @@ static inline void cpumask_copy(struct cpumask *dstp,
 static inline int cpumask_parse_user(const char __user *buf, int len,
 				     struct cpumask *dstp)
 {
-	return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpu_ids);
+	return bitmap_parse_user(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
 }
 
 /**
@@ -575,7 +575,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len,
 				     struct cpumask *dstp)
 {
 	return bitmap_parselist_user(buf, len, cpumask_bits(dstp),
-				     nr_cpu_ids);
+				     nr_cpumask_bits);
 }
 
 /**
@@ -590,7 +590,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
 	char *nl = strchr(buf, '\n');
 	unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);
 
-	return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpu_ids);
+	return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
 }
 
 /**
@@ -602,7 +602,7 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
  */
 static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
 {
-	return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpu_ids);
+	return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits);
 }
 
 /**

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web