Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp451009ybi; Fri, 31 May 2019 04:11:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqw73XW22ujnM+Dl83oK8yK6k7YrNQdwIyjBoWFx3rc1SkCM6eFboUZv3DPzbfNOhkR98YVf X-Received: by 2002:a63:c14:: with SMTP id b20mr8589216pgl.163.1559301067997; Fri, 31 May 2019 04:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559301067; cv=none; d=google.com; s=arc-20160816; b=oxO4RNgC31tQUZsRYzQCsgfbtdOVfGrJmB7axYAj7uAFj/YTaItOlyAthP28vUfVOh L0m8c5PREVSq0Xo7pkBuX8LYaEH5mkDZzc0dSwlvr173+fIW8aVsZ06ym8blcxB28I+N MKaeHrQC8XfxgsyKHgPdsAdZGCtFRJjOYmiV7SVgMQK/KEqQ2l0tQ457ZkzMRKEqFu5s DY55Dv8AzgJf6RBGplCdkiEFm1OcJPdarUJSw6maCp0nehsTsCswYh/k+j0yPgMRYab2 VSFTxQMQPzUG8WN2YT/qiOOfwYBLWWQemSz3ItYyxCt5s//E+Zj66yeL5nJeKNT+zDkp b8Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8FodIdoRggqYpcfQ8IzxUymg8eKDtRxFytfKCu5DB9o=; b=XUsMsQoKeUxVNbGRYbjTjO0XhVZ2IJ2Bdt9x9wwkKZS6Y2dlsWoI9K1dxu1kl/7j4V gJ3B+6pnNogXNiOE8ThSVldK0RTHmaL5Us5WZZ8pD1Ymb1C0BG+ZL+3St8ZbKrD9Ddc4 Bily3e7+pBATbI0DlFrsgzA2xzXmQANMlKJlfZrMAyoJ0RsT5emH42cDxvk4nf05GisJ V7NpvEVB2ihVIhDkHdhZH+M0Y8mEbuJMgfVaCKSGEk+ddUkPIgCi2nK0FEdxxhRV1YVB S58yDsb2YymHYaoJXn2jPt3Nj5Q1tz82NxNK1kJCNvz7joPtkjXPsQp4F2GwDnGN4ckB Bpmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=xu2eMCvp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a128si5757218pgc.242.2019.05.31.04.10.45; Fri, 31 May 2019 04:11:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=xu2eMCvp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727106AbfEaLJZ (ORCPT + 99 others); Fri, 31 May 2019 07:09:25 -0400 Received: from merlin.infradead.org ([205.233.59.134]:59738 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726240AbfEaLJY (ORCPT ); Fri, 31 May 2019 07:09:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8FodIdoRggqYpcfQ8IzxUymg8eKDtRxFytfKCu5DB9o=; b=xu2eMCvpPsW5sOGQjGrgPouad Sj/Oj86A4dMjx7iMebMebAizyuYOW3QMwVmGxrADtL2Ca/k+dY2rlO9NreoOLfg95LpG0bYGsIxI8 CtEthcD7L40SrBvDIPy7L86mY3aoR31mettwPQ3wtTwTXKcv0bRlxbsGMeh8miik97qACtRR7PDEy JIeEw+wg4hhqM0nHEFK0LBcbUIivq8qfkg7Z3grUK4IzYHufz8NpSJNEtj3gsFV/H4HFfVZDwTorf G55cTnOMWKf0rF5VrbJ7s88OpckRH77nPbe3Wx7IvuxaJZrSPM8M8RXvIsGXtWMzabjrGmcCvUQo1 ITJRfMwvA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1hWfOZ-0004hP-FW; Fri, 31 May 2019 11:08:24 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A7B55201B8CFE; Fri, 31 May 2019 13:08:20 +0200 (CEST) Date: Fri, 31 May 2019 13:08:20 +0200 From: Peter Zijlstra To: Vineeth Remanan Pillai Cc: Nishanth Aravamudan , Julien Desfossez , Tim Chen , mingo@kernel.org, tglx@linutronix.de, pjt@google.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, subhra.mazumdar@oracle.com, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini Subject: Re: [RFC PATCH v3 10/16] sched: Core-wide rq->lock Message-ID: <20190531110820.GP2623@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 29, 2019 at 08:36:46PM +0000, Vineeth Remanan Pillai wrote: > + * The static-key + stop-machine variable are needed such that: > + * > + * spin_lock(rq_lockp(rq)); > + * ... > + * spin_unlock(rq_lockp(rq)); > + * > + * ends up locking and unlocking the _same_ lock, and all CPUs > + * always agree on what rq has what lock. > @@ -5790,8 +5854,15 @@ int sched_cpu_activate(unsigned int cpu) > /* > * When going up, increment the number of cores with SMT present. > */ > - if (cpumask_weight(cpu_smt_mask(cpu)) == 2) > + if (cpumask_weight(cpu_smt_mask(cpu)) == 2) { > static_branch_inc_cpuslocked(&sched_smt_present); > +#ifdef CONFIG_SCHED_CORE > + if (static_branch_unlikely(&__sched_core_enabled)) { > + rq->core_enabled = true; > + } > +#endif > + } > + > #endif > set_cpu_active(cpu, true); > > @@ -5839,8 +5910,16 @@ int sched_cpu_deactivate(unsigned int cpu) > /* > * When going down, decrement the number of cores with SMT present. > */ > - if (cpumask_weight(cpu_smt_mask(cpu)) == 2) > + if (cpumask_weight(cpu_smt_mask(cpu)) == 2) { > +#ifdef CONFIG_SCHED_CORE > + struct rq *rq = cpu_rq(cpu); > + if (static_branch_unlikely(&__sched_core_enabled)) { > + rq->core_enabled = false; > + } > +#endif > static_branch_dec_cpuslocked(&sched_smt_present); > + > + } > #endif I'm confused, how doesn't this break the invariant above? That is, all CPUs must at all times agree on the value of rq_lockp(), and I'm not seeing how that is true with the above changes.