From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753062AbcGYRtI (ORCPT ); Mon, 25 Jul 2016 13:49:08 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37220 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752249AbcGYRtH (ORCPT ); Mon, 25 Jul 2016 13:49:07 -0400 X-IBM-Helo: d01dlp03.pok.ibm.com X-IBM-MailFrom: paulmck@linux.vnet.ibm.com Date: Mon, 25 Jul 2016 10:49:21 -0700 From: "Paul E. McKenney" To: Oleg Nesterov Cc: Peter Zijlstra , mingo@kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, john.stultz@linaro.org, dimitrysh@google.com, romlem@google.com, ccross@google.com, tkjos@google.com Subject: Re: [PATCH] rcu_sync: simplify the state machine, introduce __rcu_sync_enter() Reply-To: paulmck@linux.vnet.ibm.com References: <20160715153840.GI7094@linux.vnet.ibm.com> <20160715164938.GA4294@redhat.com> <20160715180140.GM7094@linux.vnet.ibm.com> <20160716171007.GA30000@redhat.com> <20160719205018.GB7094@linux.vnet.ibm.com> <20160720171602.GA5059@redhat.com> <20160720213144.GM7094@linux.vnet.ibm.com> <20160721173435.GB22488@redhat.com> <20160722032641.GE7094@linux.vnet.ibm.com> <20160725170116.GA24149@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160725170116.GA24149@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16072517-0044-0000-0000-000000BE41DC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16072517-0045-0000-0000-000004D4721C Message-Id: <20160725174921.GM7094@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-07-25_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607250204 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 25, 2016 at 07:01:17PM +0200, Oleg Nesterov wrote: > Paul, sorry for delay. > > On 07/21, Paul E. McKenney wrote: > > > > On Thu, Jul 21, 2016 at 07:34:36PM +0200, Oleg Nesterov wrote: > > > On 07/20, Paul E. McKenney wrote: > > > > > > > > On Wed, Jul 20, 2016 at 07:16:03PM +0200, Oleg Nesterov wrote: > > > > > > > > > Now, suppose we add the additional enter/exit's: > > > > > > > > > > freeze_super(sb) > > > > > { > > > > > // this doesn't block > > > > > __rcu_sync_enter(SEM3); > > > > > __rcu_sync_enter(SEM2); > > > > > __rcu_sync_enter(SEM1); > > > > > > > > > > down_write(&sb->s_umount); > > > > > if (NEED_TO_FREEZE) { > > > > > percpu_down_write(SEM1); > > > > > > > > The above waits for the grace period initiated by __rcu_sync_enter(), > > > > correct? Presumably "yes", because it will invoke rcu_sync_enter(), which > > > > will see the state as GP_ENTER, and will thus wait. > > > > > > But if down_write() blocks and/or NEED_TO_FREEZE takes some time it > > > could already see the GP_PASSED state, or at least it can sleep less. > > > > > > > But your point is that if !NEED_TO_FREEZE, we will get here without > > > > waiting for a grace period. > > > > > > > > But why aren't the __rcu_sync_enter() and rcu_sync_exit() calls inside > > > > the "if" statement? > > > > > > Yes, if we do __rcu_sync_enter() inside "if", then rcu_sync_exit() can't > > > hit GP_ENTER. > > > > > > But why we should disallow this use-case? It does not complicate the code > > > at all. > > > > I do agree that it doesn't complicate the current implementation. > > But it relies on a global lock, so I am not at all confident that this > > implementation is the final word. > > Hmm. which global lock? Or did you mean freeze_super(), not rcu_sync? OK, you are right, they are per-superblock locks rather than being global locks. Still, given that workloads that hammer a single filesystem hard are quite common, it might still eventually be of some concern. > > And speaking of global locks, failing to discourage the pattern above > > means that the code is unnecessarily acquiring three global locks, > > which doesn't seem like a good thing to me. > > Well, I do not agree, but this wasn't written by me. Just in case, all these > locks above are not really global, they are per-sb, but this is minor. Agreed. > And the patches which changed sb->s_writers to use percpu_rw_semaphore/rcu_sync > didn't change this logic. > > Except the old implementation was buggy, and the readers were slower than now. > > > I agree that there are use cases for beginning-of-time __rcu_sync_enter() > > or whatever we end up naming it. > > OK, at least iiuc you agree that cgroup_init() can use __rcu_sync_enter(). > As for other potential use-cases, we will disccuss this later. I will have > to CC you anyway ;) > > So I'll send v2 with renames after I test it. Thanks again. Sounds good! Thanx, Paul