From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751142AbdK1GXd (ORCPT ); Tue, 28 Nov 2017 01:23:33 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:39213 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbdK1GXb (ORCPT ); Tue, 28 Nov 2017 01:23:31 -0500 X-Google-Smtp-Source: AGs4zMbQiV8UuknZlM5Ubbep3lgEcqcR83zRqlZpWcvLKQWqITRFbUVKFVehwU7IWdFrzDqQPbt7iw== Date: Tue, 28 Nov 2017 15:23:26 +0900 From: Sergey Senozhatsky To: Byungchul Park Cc: Steven Rostedt , LKML , akpm@linux-foundation.org, linux-mm@kvack.org, Cong Wang , Dave Hansen , Johannes Weiner , Mel Gorman , Michal Hocko , Petr Mladek , Sergey Senozhatsky , Vlastimil Babka , yuwang.yuwang@alibabab-inc.com, Peter Zijlstra , Linus Torvalds , Jan Kara , Mathieu Desnoyers , Tetsuo Handa , rostedt@rostedt.homelinux.com, kernel-team@lge.com Subject: Re: [PATCH v4] printk: Add console owner and waiter logic to load balance console writes Message-ID: <20171128062326.GA1907@jagdpanzerIV> References: <20171108102723.602216b1@gandalf.local.home> <20171127084822.GA15859@X58A-UD3R> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171127084822.GA15859@X58A-UD3R> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On (11/27/17 17:48), Byungchul Park wrote: [..] > > + /* Owner will clear console_waiter on hand off */ > > + while (READ_ONCE(console_waiter)) > > + cpu_relax(); > > + > > + 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_); > > I'm afraid if it's ok even not to lock(or trylock) actually here. Is there > any problem if you call console_trylock() instead of mutex_acquire() here? console_trylock() will not work. console_trylock() implies that the current printing process does up(), which a) opens a race with possible console_lock()/console_trylock() from foreign CPUs, and b) additionally wakes up a task from console_sem wait list [if there was one]. so chances are some other CPU potentially can acquire the lock ahead of waiter, forcing the waiter to continue spinning on console_sem. and the bad news are a) it's spinning with local IRQs disabled and b) that another CPU, which has acquired the console_sem, can schedule under console_sem. anyway, we are not going to merge this patch. we already have discussed that in V3 thread: https://marc.info/?l=linux-kernel&m=151019815721161&w=2 https://marc.info/?l=linux-kernel&m=151020275921953&w=2 https://marc.info/?l=linux-kernel&m=151020404622181&w=2 https://marc.info/?l=linux-kernel&m=151020565222469&w=2 I took some parts of the Steven's patch set, tho, and backported them to the current printk_kthread series. -ss