From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755822AbdKBRLE (ORCPT ); Thu, 2 Nov 2017 13:11:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:45866 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755742AbdKBRLC (ORCPT ); Thu, 2 Nov 2017 13:11:02 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CAB48218AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Thu, 2 Nov 2017 13:10:59 -0400 From: Steven Rostedt To: Tetsuo Handa Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Cong Wang , Dave Hansen , Johannes Weiner , Mel Gorman , Michal Hocko , Petr Mladek , Sergey Senozhatsky , Vlastimil Babka , "yuwang.yuwang" , Peter Zijlstra , Linus Torvalds , Jan Kara , Mathieu Desnoyers Subject: Re: [PATCH v2] printk: Add console owner and waiter logic to load balance console writes Message-ID: <20171102131059.4d8935a9@gandalf.local.home> In-Reply-To: <20171102130605.05e987e8@gandalf.local.home> References: <1509017339-4802-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> <20171102115625.13892e18@gandalf.local.home> <20171102130605.05e987e8@gandalf.local.home> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 Nov 2017 13:06:05 -0400 Steven Rostedt wrote: > + raw_spin_lock(&console_owner_lock); > + waiter = console_waiter; > + console_owner = NULL; > + raw_spin_unlock(&console_owner_lock); > + > + /* > + * If there is a waiter waiting for us, then pass the > + * rest of the work load over to that waiter. > + */ > + if (waiter) > + break; > + Hmm, do I need a READ_ONCE() here? Can gcc do the load of console_waiter outside the spin lock where if (waiter) is done? Although it doesn't really matter, but it just makes the code more fragile if it can. Should this be: raw_spin_lock(&console_owner_lock); waiter = READ_ONCE(console_waiter); console_owner = NULL; raw_spin_unlock(&console_owner_lock); /* * If there is a waiter waiting for us, then pass the * rest of the work load over to that waiter. */ if (waiter) break; ? -- Steve