Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp117152pxy; Wed, 28 Apr 2021 00:19:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFUJYQ/SMvecCVFl6e9LamHLbIerh/vU2R8nfnJSp6zy12QzhvWzrckrrrTCVUhwaTVbLs X-Received: by 2002:a05:6402:488:: with SMTP id k8mr9111025edv.233.1619594355775; Wed, 28 Apr 2021 00:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619594355; cv=none; d=google.com; s=arc-20160816; b=PUfOg39RcrghUo3eCRQ4ifs5n6g7kFtRQuBsD4/6R1X6HmWhvvq2CAf6eAVFtcE6TC qzWUH8nllYeRxE+KdFdtkYudiTjY+BA+jvBxcav0MzPZ2fiIzAn9L7+OmgW69+v33RT0 jd5Lep1uOYpOa0AbsM/Q01weXgKUWwpS+Krq2uFQjdxJ8nNB1oOLzN+Btkh55Y25KnOq 8fBqPMVvmXy5MJpYb859kcRvAiV8ZzpiMpvsJaNMjAqEPdbQysbDpVxcipraxX/Xvd71 KKBPzhfdLbwWEdPOWwjiKjXhbf9hOUNz4b11vL1NwRMTrTAEJi/yGlkd2S+/4B05bzYL jQzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YAx1czeZMGTOngYcTaYGWSs9XW5iqQk2Rryh4aE/lZA=; b=bmm1XFgiZMRLJNJX3STlYwg3h7+XpaZySRAX2SpsCIYj5oWyw6pvak8/twrLGzZ7fl GL04uk+X8CTcEasw5RKjM5Vd+Grlcuu3LX16wLraH3mUO5NtJIw6LVZOb0r50tt8IFwF Px2wInlbnNFsTfkIV6/13ZKRvyDqPdR2ty9PE4s5sFX+MdcUiEbMmMg16lzOdpRAiR6S G1npjdSq6uM3V9pwpJuZwIXFz+BD9k5keDxh/5eiSYskNjrImtRdh4Hl/vSlQBU1zWoq 1V6ZRGcufXhZAWLBQsI/U+RWSsTEM9wI4zq5jJKDWXdFxnfO9GRD4AiGAAHJWdFfYKgB 8BZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JHGcuwZv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p15si2146451ejj.88.2021.04.28.00.18.52; Wed, 28 Apr 2021 00:19:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JHGcuwZv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236666AbhD1HQI (ORCPT + 99 others); Wed, 28 Apr 2021 03:16:08 -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.