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=-12.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 897CBC64E7A for ; Tue, 1 Dec 2020 16:58:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B66A20758 for ; Tue, 1 Dec 2020 16:58:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="2ELRyePo"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="gB+zf/56" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B66A20758 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JqSfUtVtHIpX7+NFlxMOKn8aIfzdmY9bAmiP3frGWA8=; b=2ELRyePo2GsGoMFqda6jJkcoT BDBrvECVSC+YfLpflG2ufjA4rrBIpdkbD1g6WXKanUCKUtHT8lRWXmzo3qE9/cxla5y4DO6EX30zb BQXzps7ufb/ehNE+ePcjnpEx4/gXv5mjFIkJuUKQvRXkGOv/T/Gy3Tk/t+GbOGvlT6DWTnWp4oLzd guWxlhMn/abhPkdbbZqPvfPYIyw5SreZP/YMf0MggdFlakgTYb460HdOG8aeEq1O9V0VCZHV4+NWk 3qPiMGJ2b3L3rkFwZhnjk5K8JHn2rEcrytNK5z9+3q21RMU90R90tWAQRnHkuaAaNrzF39dq24YL0 ljVFCSL+w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kk8xg-0003vw-1R; Tue, 01 Dec 2020 16:57:08 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kk8xc-0003u4-Om for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2020 16:57:05 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B17992151B; Tue, 1 Dec 2020 16:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606841823; bh=+4ZrlHG5vhlXWRw+9FvtNpOLKhlitTQsHmck6tUTTfc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gB+zf/56lvQEVYhYjfWTh9bKEpDsPjMrBPoFmBRNL61Xf71+qZcHZMyn8HQNFAa40 MYfNo69z4/mDIlvPx84lFQ5x0qs4WPQFZ8ELrTZySn53jsxlzG/j330EQMGK22Cr9s eMkKnw5P8gYhp1f7ja8k5z3nSpebLrqOgVcZmtFA= Date: Tue, 1 Dec 2020 16:56:57 +0000 From: Will Deacon To: Qais Yousef Subject: Re: [PATCH v4 07/14] sched: Introduce restrict_cpus_allowed_ptr() to limit task CPU affinity Message-ID: <20201201165656.GE27783@willie-the-truck> References: <20201124155039.13804-1-will@kernel.org> <20201124155039.13804-8-will@kernel.org> <20201127131916.ncoqmg62dselezyl@e107158-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201127131916.ncoqmg62dselezyl@e107158-lin.cambridge.arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201201_115704_952752_589F447A X-CRM114-Status: GOOD ( 19.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Marc Zyngier , kernel-team@android.com, Vincent Guittot , Juri Lelli , Quentin Perret , Peter Zijlstra , Catalin Marinas , Johannes Weiner , linux-kernel@vger.kernel.org, Ingo Molnar , Li Zefan , Greg Kroah-Hartman , Tejun Heo , Suren Baghdasaryan , Morten Rasmussen , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 27, 2020 at 01:19:16PM +0000, Qais Yousef wrote: > On 11/24/20 15:50, Will Deacon wrote: > > [...] > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index d2003a7d5ab5..818c8f7bdf2a 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -1860,24 +1860,18 @@ void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask) > > } > > > > /* > > - * Change a given task's CPU affinity. Migrate the thread to a > > - * proper CPU and schedule it away if the CPU it's executing on > > - * is removed from the allowed bitmask. > > - * > > - * NOTE: the caller must have a valid reference to the task, the > > - * task must not exit() & deallocate itself prematurely. The > > - * call is not atomic; no spinlocks may be held. > > + * Called with both p->pi_lock and rq->lock held; drops both before returning. > > nit: wouldn't it be better for the caller to acquire and release the locks? > Not a big deal but it's always confusing when half of the work done outside the > function and the other half done inside. That came up in the last version of the patches iirc, but the problem is that __set_cpus_allowed_ptr_locked() can trigger migration, which can drop the lock and take another one for the new runqueue. Given that this function is internal to the scheduler, I think we can probably live with it. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel