public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin Steigerwald <martin.steigerwald@teamix.de>
To: Ingo Molnar <mingo@kernel.org>, Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	Balbir Singh <balbir@in.ibm.com>,
	Shailabh Nagar <nagar@watson.ibm.com>,
	Jay Lan <jlan@engr.sgi.com>,
	Martin Steigerwald <martin@lichtvoll.de>,
	Gerlof Langeveld <gerlof.langeveld@atoptool.nl>,
	Marc Haber <mh+debian-packages@zugschlus.de>,
	Martin <martin@lichtvoll.de>
Subject: [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly
Date: Mon, 19 Dec 2016 13:06:00 +0100	[thread overview]
Message-ID: <5967400.cFS0L5jxeH@merkaba> (raw)

[-- Attachment #1: Type: text/plain, Size: 3963 bytes --]

Hello Ingo, Peter, Nicolas, Andrew, Balbir, Shailabh, Jay, Gerlof and Marc,

starting from a Debian bug report of mine, Gerlof Langeveld, developer of 
system and process monitor atop¹, found two issues with process accounting.

[1] http://atoptool.nl/


I did some guess work on who might be the maintainer for this, but please feel 
free to add further Cc´s as you see fit. Or ask for removal for Cc if you are 
not working on this anymore.

Gerlof found two issues which I also reported to the kernel bug tracker. I 
copy and paste the summaries that Gerlof prepared:


1) Sometimes process accounting does not work at all.

The acct() system call (to activate process accounting) return value 0, 
which means that process accounting is activated successfully.
However, no process accounting records are written whatsoever. This 
situation can be reproduced with the program 'acctdemo.c'
that you can find as attachment. When this program gives the message 
"found a process accounting record!", the situation is okay
and process accounting works fine to the file '/tmp/mypacct'. When the 
message 'No process accounting record yet....' is repeatedly given,
process accounting does not work and will not work at all. It might be 
that you have to start this program several times before you get
this situation (preferably start/finish lots of processes in the mean time).
This problem is probably caused by a new mechanism introduced in the 
kernel code (..../linux/kernel/acct.c) that is called 'slow accounting'
and has to be solved in the kernel code.

I experience this problem on Debian8 with a 4.8 kernel and on CentOS7 
with a 4.8 kernel.

I reported this as:

Bug 190271 - process accounting sometimes does not work 
https://bugzilla.kernel.org/show_bug.cgi?id=190271



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


Marc Haber, maintainer of atop package, Gerlof Langeveld, developer of atop 
and I are currently discussing workarounds with atop and/or systemd service 
fail for the time till upstream kernels with this issues fixed are shipped by 
distributions. Still it would be nice to remove those work-arounds and have 
the kernel work correctly again at some time in the future.

Thanks,
-- 
Martin Steigerwald  | Trainer

teamix GmbH
Südwestpark 43
90449 Nürnberg

Tel.:  +49 911 30999 55 | Fax: +49 911 30999 99
mail: martin.steigerwald@teamix.de | web:  http://www.teamix.de | blog: http://blog.teamix.de

Amtsgericht Nürnberg, HRB 18320 | Geschäftsführer: Oliver Kügow, Richard Müller

teamix Support Hotline: +49 911 30999-112
 
 *** Bitte liken Sie uns auf Facebook: facebook.com/teamix ***


[-- Attachment #2: acctdemo.c --]
[-- Type: text/x-csrc, Size: 764 bytes --]

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

#define ACCTFILE	"/tmp/mypacct"

main()
{
	int  fd;
	char buf[1024];

	if ( (fd = open(ACCTFILE, O_RDWR|O_CREAT|O_TRUNC, 0777)) == -1)
	{
		perror("Open " ACCTFILE);
		exit(1);
	}

	if (acct(ACCTFILE) == -1)
	{
		perror("Switch on accounting");
		exit(1);
	}

	if ( fork() == 0 )	// fork new process
		exit(0);	// child process: finish


	// parent process:
	//	wait for child to finish

	wait((int *)0);

	// 	read the process accounting record of the finished child

	while (read(fd, buf, sizeof buf) == 0)
	{
		printf("No process accounting record yet....\n");
		sleep(1);
	}

	printf("Yeeeeah, found a process accounting record!\n");
}

             reply	other threads:[~2016-12-19 12:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 12:06 Martin Steigerwald [this message]
2016-12-19 13:19 ` [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly Peter Zijlstra
2016-12-19 13:50   ` Martin Steigerwald
2016-12-19 14:02     ` Peter Zijlstra
2016-12-19 17:25 ` Peter Zijlstra
2017-02-06 10:39   ` Martin Steigerwald
2017-02-06 16:20     ` Tejun Heo
2017-02-06 18:24       ` [PATCH] cpumask: use nr_cpumask_bits for parsing functions Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2017-02-10 21:56 [REGRESSION] Two issues that prevent process accounting (taskstats) from working correctly Dmitry Romanov
2017-02-12 15:44 ` Dmitry Romanov
2017-03-08 11:14   ` Richard Genoud

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=5967400.cFS0L5jxeH@merkaba \
    --to=martin.steigerwald@teamix.de \
    --cc=akpm@osdl.org \
    --cc=balbir@in.ibm.com \
    --cc=gerlof.langeveld@atoptool.nl \
    --cc=jlan@engr.sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@lichtvoll.de \
    --cc=mh+debian-packages@zugschlus.de \
    --cc=mingo@elte.hu \
    --cc=mingo@kernel.org \
    --cc=nagar@watson.ibm.com \
    --cc=nicolas.dichtel@6wind.com \
    --cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox