All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Byungchul Park <byungchul.park@lge.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Mel Gorman <mgorman@suse.de>, Michal Hocko <mhocko@kernel.org>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Peter Zijlstra <peterz@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jan Kara <jack@suse.cz>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	rostedt@rostedt.homelinux.com, kernel-team@lge.com
Subject: Re: [PATCH v4] printk: Add console owner and waiter logic to load balance console writes
Date: Fri, 8 Dec 2017 15:00:22 +0100	[thread overview]
Message-ID: <20171208140022.uln4t5e5drrhnvvt@pathway.suse.cz> (raw)
In-Reply-To: <20171128014229.GA2899@X58A-UD3R>

Hello,

thanks a lot for help. I am sorry for the late response. I wanted to
handle this mail with a clean head.

On Tue 2017-11-28 10:42:29, Byungchul Park wrote:
> On Fri, Nov 24, 2017 at 04:58:16PM +0100, Petr Mladek wrote:
> > @@ -1797,13 +1797,6 @@ asmlinkage int vprintk_emit(int facility, int level,
> >  				spin_release(&console_owner_dep_map, 1, _THIS_IP_);
> >  				printk_safe_exit_irqrestore(flags);
> >  
> > -				/*
> > -				 * The owner passed the console lock to us.
> > -				 * Since we did not spin on console lock, annotate
> > -				 * this as a trylock. Otherwise lockdep will
> > -				 * complain.
> > -				 */
> > -				mutex_acquire(&console_lock_dep_map, 0, 1, _THIS_IP_);
> 
> Hello Petr,
> 
> IMHO, it would get unbalanced if you only remove this mutex_acquire().
> 
> >  				console_unlock();
> >  				printk_safe_enter_irqsave(flags);
> >  			}
> > @@ -2334,10 +2327,10 @@ void console_unlock(void)
> >  		/* The waiter is now free to continue */
> >  		spin_release(&console_owner_dep_map, 1, _THIS_IP_);
> >  		/*
> > -		 * Hand off console_lock to waiter. The waiter will perform
> > -		 * the up(). After this, the waiter is the console_lock owner.
> > +		 * Hand off console_lock to waiter. After this, the waiter
> > +		 * is the console_lock owner.
> >  		 */
> > -		mutex_release(&console_lock_dep_map, 1, _THIS_IP_);
> 
> IMHO, this release() should be moved to somewhere properly.
> 
> > +		lock_commit_crosslock((struct lockdep_map *)&console_lock_dep_map);
> >  		printk_safe_exit_irqrestore(flags);
> >  		/* Note, if waiter is set, logbuf_lock is not held */
> >  		return;
> 
> However, now that cross-release was introduces, lockdep can be applied
> to semaphore operations. Actually, I have a plan to do that. I think it
> would be better to make semaphore tracked with lockdep and remove all
> these manual acquire() and release() here. What do you think about it?

IMHO, it would be great to add lockdep annotations into semaphore
operations.

Well, I am not sure if this would be enough in this case. I think
that the locking dependency in this Steven's patch is special.
The semaphore is passed from one owner to another one without
unlocking. Both sides wait for each other using a busy loop.

The busy loop/waiting is activated only when the current owner
is not sleeping to avoid softlockup. I think that it is
a kind of conditional cross-release or something even
more special.

Sigh, I wish I was able to clean my head even more to be
able to think about this.

Best Regards,
Petr

WARNING: multiple messages have this Message-ID (diff)
From: Petr Mladek <pmladek@suse.com>
To: Byungchul Park <byungchul.park@lge.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Mel Gorman <mgorman@suse.de>, Michal Hocko <mhocko@kernel.org>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Peter Zijlstra <peterz@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jan Kara <jack@suse.cz>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	rostedt@home.goodmis.org, kernel-team@lge.com
Subject: Re: [PATCH v4] printk: Add console owner and waiter logic to load balance console writes
Date: Fri, 8 Dec 2017 15:00:22 +0100	[thread overview]
Message-ID: <20171208140022.uln4t5e5drrhnvvt@pathway.suse.cz> (raw)
In-Reply-To: <20171128014229.GA2899@X58A-UD3R>

Hello,

thanks a lot for help. I am sorry for the late response. I wanted to
handle this mail with a clean head.

On Tue 2017-11-28 10:42:29, Byungchul Park wrote:
> On Fri, Nov 24, 2017 at 04:58:16PM +0100, Petr Mladek wrote:
> > @@ -1797,13 +1797,6 @@ asmlinkage int vprintk_emit(int facility, int level,
> >  				spin_release(&console_owner_dep_map, 1, _THIS_IP_);
> >  				printk_safe_exit_irqrestore(flags);
> >  
> > -				/*
> > -				 * The owner passed the console lock to us.
> > -				 * Since we did not spin on console lock, annotate
> > -				 * this as a trylock. Otherwise lockdep will
> > -				 * complain.
> > -				 */
> > -				mutex_acquire(&console_lock_dep_map, 0, 1, _THIS_IP_);
> 
> Hello Petr,
> 
> IMHO, it would get unbalanced if you only remove this mutex_acquire().
> 
> >  				console_unlock();
> >  				printk_safe_enter_irqsave(flags);
> >  			}
> > @@ -2334,10 +2327,10 @@ void console_unlock(void)
> >  		/* The waiter is now free to continue */
> >  		spin_release(&console_owner_dep_map, 1, _THIS_IP_);
> >  		/*
> > -		 * Hand off console_lock to waiter. The waiter will perform
> > -		 * the up(). After this, the waiter is the console_lock owner.
> > +		 * Hand off console_lock to waiter. After this, the waiter
> > +		 * is the console_lock owner.
> >  		 */
> > -		mutex_release(&console_lock_dep_map, 1, _THIS_IP_);
> 
> IMHO, this release() should be moved to somewhere properly.
> 
> > +		lock_commit_crosslock((struct lockdep_map *)&console_lock_dep_map);
> >  		printk_safe_exit_irqrestore(flags);
> >  		/* Note, if waiter is set, logbuf_lock is not held */
> >  		return;
> 
> However, now that cross-release was introduces, lockdep can be applied
> to semaphore operations. Actually, I have a plan to do that. I think it
> would be better to make semaphore tracked with lockdep and remove all
> these manual acquire() and release() here. What do you think about it?

IMHO, it would be great to add lockdep annotations into semaphore
operations.

Well, I am not sure if this would be enough in this case. I think
that the locking dependency in this Steven's patch is special.
The semaphore is passed from one owner to another one without
unlocking. Both sides wait for each other using a busy loop.

The busy loop/waiting is activated only when the current owner
is not sleeping to avoid softlockup. I think that it is
a kind of conditional cross-release or something even
more special.

Sigh, I wish I was able to clean my head even more to be
able to think about this.

Best Regards,
Petr

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-12-08 14:00 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 15:27 [PATCH v4] printk: Add console owner and waiter logic to load balance console writes Steven Rostedt
2017-11-08 15:27 ` Steven Rostedt
2017-11-09 10:12 ` Michal Hocko
2017-11-09 10:12   ` Michal Hocko
2017-11-09 10:22   ` [PATCH v4] printk: Add console owner and waiter logic to loadbalance " Tetsuo Handa
2017-11-09 10:22     ` Tetsuo Handa
2017-11-09 10:26     ` Michal Hocko
2017-11-09 10:26       ` Michal Hocko
2017-11-09 11:03       ` Tetsuo Handa
2017-11-09 11:03         ` Tetsuo Handa
2017-11-09 11:31         ` Michal Hocko
2017-11-09 11:31           ` Michal Hocko
2017-11-09 12:07           ` Tetsuo Handa
2017-11-09 12:07             ` Tetsuo Handa
2017-11-24 15:54 ` [PATCH v4] printk: Add console owner and waiter logic to load balance " Petr Mladek
2017-11-24 15:54   ` Petr Mladek
2017-11-24 15:58   ` Petr Mladek
2017-11-24 15:58     ` Petr Mladek
2017-11-27  8:53     ` Byungchul Park
2017-11-27  8:53       ` Byungchul Park
2017-11-28  1:42     ` Byungchul Park
2017-11-28  1:42       ` Byungchul Park
2017-12-08 14:00       ` Petr Mladek [this message]
2017-12-08 14:00         ` Petr Mladek
2017-12-12  5:39         ` Sergey Senozhatsky
2017-12-12  5:39           ` Sergey Senozhatsky
2017-12-12 19:27           ` Steven Rostedt
2017-12-12 19:27             ` Steven Rostedt
2017-12-13  1:50             ` Sergey Senozhatsky
2017-12-13  1:50               ` Sergey Senozhatsky
2017-12-14 14:34             ` Petr Mladek
2017-12-14 14:34               ` Petr Mladek
2017-12-14 13:51     ` Petr Mladek
2017-12-14 13:51       ` Petr Mladek
2017-11-27  8:48 ` Byungchul Park
2017-11-27  8:48   ` Byungchul Park
2017-11-28  6:23   ` Sergey Senozhatsky
2017-11-28  6:23     ` Sergey Senozhatsky
2017-12-22 10:31 ` Petr Mladek
2017-12-22 10:31   ` Petr Mladek
2017-12-22 12:44   ` Steven Rostedt
2017-12-22 12:44     ` Steven Rostedt
2018-01-10 12:50     ` Petr Mladek
2018-01-10 12:50       ` Petr Mladek
  -- strict thread matches above, loose matches on Subject: below --
2017-11-08 15:13 Steven Rostedt
2017-11-08 15:03 Steven Rostedt
2017-11-08 15:10 ` Steven Rostedt

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=20171208140022.uln4t5e5drrhnvvt@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=akpm@linux-foundation.org \
    --cc=byungchul.park@lge.com \
    --cc=dave.hansen@intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=jack@suse.cz \
    --cc=kernel-team@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mgorman@suse.de \
    --cc=mhocko@kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=rostedt@rostedt.homelinux.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    --cc=xiyou.wangcong@gmail.com \
    /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.