Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp103733rwr; Wed, 3 May 2023 23:24:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KNkJZgS7tmYKh6/OcpxoidQVdgZlePuyQE9P+diXuEsqId7yA0yMCQ4OT70PJ5Bqw9Mf/ X-Received: by 2002:a17:903:230c:b0:19c:fc41:2dfd with SMTP id d12-20020a170903230c00b0019cfc412dfdmr3194638plh.29.1683181496415; Wed, 03 May 2023 23:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683181496; cv=none; d=google.com; s=arc-20160816; b=mCjvRV/jMD/R6iYYav2vHjZ5inKTphHPYA+/TSDF3CYfUFz4WmY5gITZIjOkFyOivx KYC6WHgd2BkLWAnPTnEQ+2h5e9sLce6neUqTQJ7SxYGpIBFkvig5P5mtDZtYh7iHPORR GtcsBWsw2Yi0Dok/c7gjnKxlWIotUg1Fut+iajoONT1A7aQD0lY67uw5gdygDrTb7K5i C6vAO7wkNBVsYfCi7WlCNTYf5YpT3iDwqzS28YVY97KDYXnGAlsHod3kSo3x7mXn2qIC ZIRE6JStLBN9PRI5DY1GWTfLI3TNpjyJf7gXlY0sqMtNAPgKRTibpISwOzjw0UazSIR/ 2XGw== 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=DfqWiyDRGB40eGYe2jGNPAj11jBf4uHEb5kd/1AH73Y=; b=qA7gqn8ttijaREkCoR5qtg8sQqA0l43dN2iS8+C/51MJomFXLNdb50IEw5aHtxmuE/ 4Wx5CF2bAiJtM/Md6YekBrbObRkfThx06YrP482C+05NRnl8BPy7rnA4roTUFl2N5Z47 c1oC+m3jdmEMA/RE2we8Z237434AyBAyp1BnXYXQ2a+xfviZlqO6bFOtEqH3nsyv6DwP 14MBmDWHQBVSj+VZ1bsSte06wT0Rk0HjYOkcZLDK5h6bqLBkURSkPuDpkLEPW5DZc9wc 5H/TG1J7VFHD/QAdjwrgTHkq6YLybUX1Ki+zjyzbFt1g8hHdtaZtEiroTb0Pho/5mwyI cqwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=jh1G+T4B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a170903120b00b001a92f0f46fbsi37781197plh.436.2023.05.03.23.24.42; Wed, 03 May 2023 23:24:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=jh1G+T4B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbjEDGTf (ORCPT + 99 others); Thu, 4 May 2023 02:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjEDGTe (ORCPT ); Thu, 4 May 2023 02:19:34 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ED7A198A; Wed, 3 May 2023 23:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=DfqWiyDRGB40eGYe2jGNPAj11jBf4uHEb5kd/1AH73Y=; b=jh1G+T4BkA9Hqha86rr270atlB 5VwBCL/FYuqlZsXl0tN57xUIihlHNN0hXZdhYF5obHg6NpfSugsRblLNfQpxC9YVbxj6uIRzHsddp KTBcXsnS9sPUo1O2QKsEvkTK3lGpdlNDQ0mSvgXDxXeFdghOK40WtYgfhXV79NTqsA3nUnp0I969U CMC3kIZOlR0BJRQO/CAEg9xEanUSQQ8Wk+Q0NR0s4hMKnb6KBoE+w9bEonYDEwg7IrhgW7OV4pfsL p5QLXOChTN+p5HhuP/ExTFbYwLe4NO5TcFy+X+sWCWDmc2UetTwys0ulbOrEaa4exgcA1Ce8chbzI h/w1z1vg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1puSIh-001eUc-10; Thu, 04 May 2023 06:18:48 +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 (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 81A733006DA; Thu, 4 May 2023 08:18:42 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 346F823BD3ADF; Thu, 4 May 2023 08:18:42 +0200 (CEST) Date: Thu, 4 May 2023 08:18:42 +0200 From: Peter Zijlstra To: Juri Lelli Cc: Ingo Molnar , Qais Yousef , Waiman Long , Tejun Heo , Zefan Li , Johannes Weiner , Hao Luo , Dietmar Eggemann , Steven Rostedt , linux-kernel@vger.kernel.org, luca.abeni@santannapisa.it, claudio@evidence.eu.com, tommaso.cucinotta@santannapisa.it, bristot@redhat.com, mathieu.poirier@linaro.org, cgroups@vger.kernel.org, Vincent Guittot , Wei Wang , Rick Yiu , Quentin Perret , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sudeep Holla Subject: Re: [PATCH v2 2/6] sched/cpuset: Bring back cpuset_mutex Message-ID: <20230504061842.GC1734100@hirez.programming.kicks-ass.net> References: <20230503072228.115707-1-juri.lelli@redhat.com> <20230503072228.115707-3-juri.lelli@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230503072228.115707-3-juri.lelli@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 03, 2023 at 09:22:24AM +0200, Juri Lelli wrote: > /* > - * There are two global locks guarding cpuset structures - cpuset_rwsem and > + * There are two global locks guarding cpuset structures - cpuset_mutex and > * callback_lock. We also require taking task_lock() when dereferencing a > * task's cpuset pointer. See "The task_lock() exception", at the end of this > - * comment. The cpuset code uses only cpuset_rwsem write lock. Other > - * kernel subsystems can use cpuset_read_lock()/cpuset_read_unlock() to > - * prevent change to cpuset structures. > + * comment. The cpuset code uses only cpuset_mutex. Other kernel subsystems > + * can use cpuset_lock()/cpuset_unlock() to prevent change to cpuset > + * structures. > * > * A task must hold both locks to modify cpusets. If a task holds > - * cpuset_rwsem, it blocks others wanting that rwsem, ensuring that it > - * is the only task able to also acquire callback_lock and be able to > - * modify cpusets. It can perform various checks on the cpuset structure > - * first, knowing nothing will change. It can also allocate memory while > - * just holding cpuset_rwsem. While it is performing these checks, various > - * callback routines can briefly acquire callback_lock to query cpusets. > - * Once it is ready to make the changes, it takes callback_lock, blocking > - * everyone else. > + * cpuset_mutex, it blocks others, ensuring that it is the only task able to > + * also acquire callback_lock and be able to modify cpusets. It can perform > + * various checks on the cpuset structure first, knowing nothing will change. > + * It can also allocate memory while just holding cpuset_mutex. While it is > + * performing these checks, various callback routines can briefly acquire > + * callback_lock to query cpusets. Once it is ready to make the changes, it > + * takes callback_lock, blocking everyone else. > * > * Calls to the kernel memory allocator can not be made while holding > * callback_lock, as that would risk double tripping on callback_lock > @@ -403,16 +402,16 @@ static struct cpuset top_cpuset = { > * guidelines for accessing subsystem state in kernel/cgroup.c > */ > > -DEFINE_STATIC_PERCPU_RWSEM(cpuset_rwsem); > +static DEFINE_MUTEX(cpuset_mutex); Perhaps extend the comment to state you explicitly want a mutex for PI etc.. ?