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


Groups > linux.kernel > #1373990

Re: [PATCH v11 3/3] printk: make printk.synchronous param rw

From Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v11 3/3] printk: make printk.synchronous param rw
Date 2016-04-08 07:30 +0200
Message-ID <rlx9w-7sb-13@gated-at.bofh.it> (permalink)
References <rll8m-6JT-19@gated-at.bofh.it> <rll8m-6JT-17@gated-at.bofh.it> <rlvU6-6xI-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On (04/08/16 12:04), Pan Xinhui wrote:
[..]
> > +/*
> > + * Init async printk via late_initcall, after core/arch/device/etc.
> > + * initialization.
> > + */
> > +static __init int init_printk_kthread(void)
> > +{
> > +	printk_initcall_done = true;
> > +	return __init_printk_kthread();
> hello, 
> 
> One confusion, Why not use a lock to protect __init_printk_kthread from parallel call? Otherwise I think there is a race.
> But for simplicity, maybe you could write codes as below.
> 
> +	int ret  = __init_printk_kthread();
> +	printk_initcall_done = true;
> +	return ret;
> 
> In my opinion, using a lock is better.

Hello,

I though about this, but isn't late_initcall() happening before kernel
starts /sbin/init? who can race with

	late_initcall() -> init_printk_kthread() -> __init_printk_kthread()?

looking at

static int __ref kernel_init(void *unused)
{
        int ret;

        kernel_init_freeable();
        /* need to finish all async __init code before freeing the memory */
        async_synchronize_full();
        free_initmem();
..

        if (!try_to_run_init_process("/sbin/init") ||
            !try_to_run_init_process("/etc/init") ||
            !try_to_run_init_process("/bin/init") ||
            !try_to_run_init_process("/bin/sh"))
                return 0;

__init (and init_printk_kthread is __init) is finished and freed by the
time kernel try_to_run_init_process. isn't it?


sysfs knob -> __init_printk_kthread() is protected by printk_sync_lock
mutex, obviously there can be parallel calls from user space.

	-ss

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v11 3/3] printk: make printk.synchronous param rw Sergey Senozhatsky <sergey.senozhatsky@gmail.com> - 2016-04-07 18:40 +0200
  Re: [PATCH v11 3/3] printk: make printk.synchronous param rw Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-08 06:10 +0200
    Re: [PATCH v11 3/3] printk: make printk.synchronous param rw Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2016-04-08 07:30 +0200
      Re: [PATCH v11 3/3] printk: make printk.synchronous param rw Pan Xinhui <xinhui@linux.vnet.ibm.com> - 2016-04-08 07:50 +0200

csiph-web