All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Kay Sievers <kay@vrfy.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Greg Kroah-Hartmann <greg@kroah.com>,
	Ingo Molnar <mingo@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RESEND 1/3] printk: convert byte-buffer to variable-length record buffer
Date: Thu, 29 Nov 2012 14:37:29 +0100	[thread overview]
Message-ID: <CAKgNAkhQuugAOChSroXFgSPQ_=zyfFOZHzL3PGfU2SdmJcmj4w@mail.gmail.com> (raw)
In-Reply-To: <CAPXgP10OW_XuPMHn=KQzaESfpNhehkUx6=hKL2dHdGytZkGmng@mail.gmail.com>

On Thu, Nov 29, 2012 at 2:28 PM, Kay Sievers <kay@vrfy.org> wrote:
> On Thu, Nov 29, 2012 at 2:18 PM, Michael Kerrisk (man-pages)
> <mtk.manpages@gmail.com> wrote:
>> On Wed, Nov 28, 2012 at 6:51 PM, Kay Sievers <kay@vrfy.org> wrote:
>
>>> Before:
>>>   syslog(SYSLOG_ACTION_SIZE_UNREAD, 0, 0) = 286965
>>>   syslog(SYSLOG_ACTION_READ_CLEAR, "<12>"..., 1000000) = 24000
>>>   syslog(SYSLOG_ACTION_SIZE_UNREAD, 0, 0) = 286965
>>>
>>> After:
>>>   syslog(SYSLOG_ACTION_SIZE_UNREAD, 0, 0) = 90402
>>>   syslog(SYSLOG_ACTION_READ_CLEAR, "<5>"..., 1000000) = 90402
>>>   syslog(SYSLOG_ACTION_SIZE_UNREAD, 0, 0) = 0
>
>> I'm going to call my report yesterday bogus. Somewhere along the way,
>> I got confused while testing something, and my statement about 2.6.31
>> behavior is wrong: the 2.6.31 and 3.5 behaviors are the same. As such,
>> your patch is unneeded. Sorry for wasting your time.
>
> I think you have been right with your report. The above pasted
> before/after from the patch commit text is actually a result of real
> testing with current git. And your initial description sounds right,
> and the patch seems to produce the expected results here. I just
> confused the numbers in your report and wrongly parsed 2.6 > 3.6.
>
> Hmm, at least do far we did not blame anybody else than ourselves as
> confused. One of us at least is right, and it looks you have been, and
> I also think the patch is at least intended to be right. :)

Okay -- I'm pretty sure I am right about being wrong ;-).

Could you do some comparative testing please between 3.5 and pre-3.5.
I have a little test program below. When I rechecked 2.6.31 and 3.5
using this program I found the behavior was the same, which is why I
conclude my report is wrong. (And also, your proposed patch in
response to my bogus report produces different behavior from 2.6.31).

Thanks,

Michael

/*#* t_klogctl.c

  klogctl(3) is the glibc interface for syslog(2)

*/

#include <sys/klog.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

#define errMsg(msg) 	do { perror(msg); } while (0)

#define errExit(msg) 	do { perror(msg); exit(EXIT_FAILURE); \
			} while (0)

#define fatal(msg) 	do { fprintf(stderr, "%s\n", msg); \
     			     exit(EXIT_FAILURE); } while (0)


/* Close the log.  Currently a NOP. */
#define SYSLOG_ACTION_CLOSE          0
/* Open the log. Currently a NOP. */
#define SYSLOG_ACTION_OPEN           1
/* Read from the log. */
#define SYSLOG_ACTION_READ           2
/* Read all messages remaining in the ring buffer. */
#define SYSLOG_ACTION_READ_ALL       3
/* Read and clear all messages remaining in the ring buffer */
#define SYSLOG_ACTION_READ_CLEAR     4
/* Clear ring buffer. */
#define SYSLOG_ACTION_CLEAR          5
/* Disable printk's to console */
#define SYSLOG_ACTION_CONSOLE_OFF    6
/* Enable printk's to console */
#define SYSLOG_ACTION_CONSOLE_ON     7
/* Set level of messages printed to console */
#define SYSLOG_ACTION_CONSOLE_LEVEL  8
/* Return number of unread characters in the log buffer */
#define SYSLOG_ACTION_SIZE_UNREAD    9
/* Return size of the log buffer */
#define SYSLOG_ACTION_SIZE_BUFFER   10


int
main(int argc, char *argv[])
{
    int s;
#define BSIZE 500000
    char buf[BSIZE];

    if (argc < 2) {
	fprintf(stderr, "Usage: %s command-num [arg]\n", argv[0]);
	exit(EXIT_FAILURE);
    }

    int cmd;

    cmd = atoi(argv[1]);

    switch (cmd) {

    case SYSLOG_ACTION_READ:		/* 2 */
	printf("SYSLOG_ACTION_READ\n");
        s = klogctl(SYSLOG_ACTION_READ, buf,
		(argc > 2) ? atoi(argv[2]) : BSIZE);
        if (s == -1)
	    errExit("klogctl-READ");
        printf("Return value: %d\n", s);

        if (write(2, buf, s) != s)
	    errMsg("write");
        break;

    case SYSLOG_ACTION_READ_ALL:	/* 3 */
    case SYSLOG_ACTION_READ_CLEAR:	/* 4 */
	if (cmd == SYSLOG_ACTION_READ_CLEAR)
	    printf("SYSLOG_ACTION_READ_CLEAR\n");
	else
	    printf("SYSLOG_ACTION_READ_ALL\n");


        s = klogctl(cmd, buf,
		(argc > 2) ? atoi(argv[2]) : BSIZE);
        if (s == -1)
	    errExit("klogctl-READ_ALL/READ_CLEAR");
        printf("Return value: %d\n", s);

        if (write(2, buf, s) != s)
	    errMsg("write");

	if (cmd == SYSLOG_ACTION_READ_CLEAR)
	    printf("Ring buffer cleared\n");
        break;

    case SYSLOG_ACTION_CLEAR:		/* 5 */
	printf("SYSLOG_ACTION_CLEAR\n");
        s = klogctl(SYSLOG_ACTION_CLEAR, NULL, 0);
        if (s == -1)
	    errExit("klogctl-CLEAR");
        printf("Return value: %d\n", s);
	printf("Ring buffer cleared\n");
	break;

    case SYSLOG_ACTION_SIZE_UNREAD:	/* 9 */
	printf("SYSLOG_ACTION_SIZE_UNREAD\n");
        s = klogctl(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0);
        if (s == -1)
	    errExit("klogctl-SIZE_UNREAD");
        printf("Number of unread bytes: %d\n", s);
	break;

    case SYSLOG_ACTION_SIZE_BUFFER:	/* 10 */
	printf("SYSLOG_ACTION_SIZE_BUFFER\n");
        s = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
        if (s == -1)
	    errExit("klogctl-SIZE_BUFFER");
        printf("Size of buffer: %d\n", s);
	break;

    default:
	fatal("Bad command");
	break;
    }

    exit(EXIT_SUCCESS);
}

  reply	other threads:[~2012-11-29 13:37 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03  0:29 [PATCH RESEND 1/3] printk: convert byte-buffer to variable-length record buffer Kay Sievers
2012-05-03 19:48 ` Peter Zijlstra
2012-05-03 19:54   ` Kay Sievers
2012-05-03 19:55     ` Peter Zijlstra
2012-05-03 19:56   ` Linus Torvalds
2012-05-03 20:02     ` Peter Zijlstra
2012-05-03 20:09       ` Linus Torvalds
2012-05-03 20:11         ` Peter Zijlstra
2012-05-03 20:18           ` Greg Kroah-Hartmann
2012-05-08  8:48 ` Sasha Levin
2012-05-08 11:14   ` Kay Sievers
2012-05-08 13:33     ` Sasha Levin
2012-05-08 14:29       ` Kay Sievers
2012-05-08 15:33         ` Kay Sievers
2012-05-08 15:57           ` Sasha Levin
2012-05-08 16:27             ` Kay Sievers
2012-05-08 22:57               ` Greg Kroah-Hartmann
2012-05-09  3:52     ` Linus Torvalds
2012-05-09  4:06       ` Joe Perches
2012-05-09  4:11       ` Sasha Levin
2012-05-09  4:27         ` Linus Torvalds
2012-05-09  4:36           ` Linus Torvalds
2012-05-09  7:07             ` Ingo Molnar
2012-05-09 13:21               ` Kay Sievers
2012-05-09 13:29               ` Kay Sievers
2012-05-10  0:54                 ` Kay Sievers
2012-05-10  1:18                   ` Linus Torvalds
2012-05-10  2:32                     ` Kay Sievers
2012-05-10  2:46                       ` Joe Perches
2012-05-10 16:39                     ` Kay Sievers
2012-05-10 16:47                       ` Linus Torvalds
2012-05-10 18:49                         ` Tony Luck
2012-05-10 19:09                         ` Kay Sievers
2012-05-10 20:14                           ` Ted Ts'o
2012-05-10 20:37                             ` Joe Perches
2012-05-10 20:39                               ` Kay Sievers
2012-05-10 20:46                                 ` Joe Perches
2012-05-10 20:52                                   ` Linus Torvalds
2012-05-10 21:11                                     ` Joe Perches
2012-05-10 21:15                                       ` Kay Sievers
2012-05-10 21:58                                       ` Linus Torvalds
2012-05-11  0:13                                         ` Joe Perches
2012-05-11  0:38                                     ` Kay Sievers
2012-05-11  1:23                                       ` Kay Sievers
2012-05-14 18:46                                         ` Kay Sievers
2012-05-10 21:01                                   ` Kay Sievers
2012-05-10 20:38                             ` Kay Sievers
2012-05-09  9:38       ` Kay Sievers
2012-05-09 13:50         ` Joe Perches
2012-05-09 14:37           ` Kay Sievers
2012-05-09 23:02             ` Yinghai Lu
2012-05-09 23:06               ` Greg Kroah-Hartmann
2012-05-10  2:30                 ` Kay Sievers
2012-05-11 10:35                   ` Sasha Levin
2012-05-11 15:19                     ` Greg KH
2012-05-11 15:22                       ` Sasha Levin
2012-05-11 15:35                       ` Linus Torvalds
2012-05-11 15:40                         ` Kay Sievers
2012-05-11 15:47                           ` Linus Torvalds
2012-05-11 19:51                             ` Mark Lord
2012-05-11 20:02                               ` Linus Torvalds
2012-05-12 18:04                                 ` Mark Lord
2012-05-12  7:43                             ` Sasha Levin
2012-05-12 18:35                               ` Linus Torvalds
2012-05-13 11:08                                 ` Kay Sievers
2012-05-13 13:22                                 ` Mark Lord
2012-05-13 18:01                                   ` Linus Torvalds
2012-05-13 22:19                                     ` Mark Lord
2012-05-14 16:40                                   ` valdis.kletnieks
2012-05-17  3:44                                 ` H. Peter Anvin
2012-05-13 21:48                               ` Kay Sievers
2012-05-13 21:30                     ` Kay Sievers
2012-05-26 11:11 ` Anton Vorontsov
2012-05-27 14:23   ` Kay Sievers
2012-05-29 16:07     ` Kay Sievers
2012-05-29 16:14       ` Joe Perches
2012-05-29 16:34         ` Kay Sievers
2012-05-29 16:51           ` Joe Perches
2012-05-29 17:11       ` Luck, Tony
2012-05-29 17:22         ` Kay Sievers
2012-05-30 11:29           ` Kay Sievers
2012-06-06  6:33       ` Greg Kroah-Hartmann
2012-06-15  0:04       ` Greg KH
2012-06-15  1:31         ` Anton Vorontsov
2012-06-15 12:07         ` Kay Sievers
2012-06-15 12:23           ` Ingo Molnar
2012-06-15 21:53             ` Greg KH
2012-06-15 12:23           ` Anton Vorontsov
2012-06-15 20:54           ` Tony Luck
2012-11-28 13:33 ` Michael Kerrisk
2012-11-28 16:22   ` Kay Sievers
2012-11-28 16:37     ` Linus Torvalds
2012-11-28 16:49       ` Kay Sievers
2012-11-28 17:51         ` Kay Sievers
2012-11-29 13:18           ` Michael Kerrisk (man-pages)
2012-11-29 13:28             ` Kay Sievers
2012-11-29 13:37               ` Michael Kerrisk (man-pages) [this message]
2012-11-29 14:08                 ` Kay Sievers
2012-11-29 14:18                   ` Michael Kerrisk (man-pages)
2012-11-29 14:31                     ` Kay Sievers

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='CAKgNAkhQuugAOChSroXFgSPQ_=zyfFOZHzL3PGfU2SdmJcmj4w@mail.gmail.com' \
    --to=mtk.manpages@gmail.com \
    --cc=greg@kroah.com \
    --cc=kay@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=torvalds@linux-foundation.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.