From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C220C433ED for ; Wed, 28 Apr 2021 07:15:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06CEB613DC for ; Wed, 28 Apr 2021 07:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236702AbhD1HQK (ORCPT ); Wed, 28 Apr 2021 03:16:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbhD1HQH (ORCPT ); Wed, 28 Apr 2021 03:16:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74EF1C061574 for ; Wed, 28 Apr 2021 00:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YAx1czeZMGTOngYcTaYGWSs9XW5iqQk2Rryh4aE/lZA=; b=JHGcuwZvy3sGa0Vl51dbGMcCTU kEkaCT8S5SuSaINe07eQ3iWSMqhOxYqWXHFt2vTWBmjS3b0nMd1JP+600AhdNmVsY5KKNskun2B68 KF8/Ie6Mob1I/Eq/d/QjzBX3unmicHdmy0K0jd+IZWz/j+/EVnOxSOkI6c86s85aI5r/1MPq+qM2o +OmBfZgb2hi7X5c+Hj+LUqmVFBMxllJ1NRiLgqxAZPyys82HWBAgs3aLtT70yA3Hy+w0O3ooU6aoL +S4Ti/d2EXeE9B93RhXoE+NTFPjb1zDUYgfqGmW4UKPTy2DtIBGsEOb4UQ0mPPiDRQhPa+C1Wh/7t ilm5yANA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lbeOI-007y9Y-Rh; Wed, 28 Apr 2021 07:13:52 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 362B030003A; Wed, 28 Apr 2021 09:13:44 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0F5F32D3DF417; Wed, 28 Apr 2021 09:13:44 +0200 (CEST) Date: Wed, 28 Apr 2021 09:13:44 +0200 From: Peter Zijlstra To: Josh Don Cc: Joel Fernandes , "Hyser,Chris" , Ingo Molnar , Vincent Guittot , Valentin Schneider , Mel Gorman , linux-kernel , Thomas Gleixner Subject: Re: [PATCH 04/19] sched: Prepare for Core-wide rq->lock Message-ID: References: <20210422120459.447350175@infradead.org> <20210422123308.196692074@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 26, 2021 at 03:21:36PM -0700, Josh Don wrote: > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index f732642e3e09..1a81e9cc9e5d 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -290,6 +290,10 @@ static void sched_core_assert_empty(void) > > static void __sched_core_enable(void) > > { > > static_branch_enable(&__sched_core_enabled); > > + /* > > + * Ensure raw_spin_rq_*lock*() have completed before flipping. > > + */ > > + synchronize_sched(); > > synchronize_rcu() Moo, I actually like synchronize_sched() because it indicates it matches a preempt disabled region. > > __sched_core_flip(true); > > sched_core_assert_empty(); > > } > > @@ -449,16 +453,22 @@ void raw_spin_rq_lock_nested(struct rq *rq, int subclass) > > { > > raw_spinlock_t *lock; > > > > + preempt_disable(); > > if (sched_core_disabled()) { > > raw_spin_lock_nested(&rq->__lock, subclass); > > + /* preempt *MUST* still be disabled here */ > > + preempt_enable_no_resched(); > > return; > > } > > This approach looks good to me. I'm guessing you went this route > instead of doing the re-check after locking in order to optimize the > disabled case? Exactly. > Recommend a comment that the preempt_disable() here pairs with the > synchronize_rcu() in __sched_core_enable(). Fair enough.