Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp849363pxu; Wed, 2 Dec 2020 05:10:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxhqolkaBspHY0/2N3XcfA0BidhghbJl6C7aPzt2/uHKF8zrAA2X9raULUb5/0dbWJgkIoH X-Received: by 2002:a17:906:ee2:: with SMTP id x2mr2306007eji.326.1606914623827; Wed, 02 Dec 2020 05:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606914623; cv=none; d=google.com; s=arc-20160816; b=CV4mhVFWsrzPNyBm9PO4ZIoeRw/m+DSeRUAHuQtRr/NJQNTXviEQNj/dNQ/FEw4itC 3JTaaO7KlP8gJsVeb3x4U18XLFb4tPwT+p1NoUtylHA+FPPbBeH9yQ+qKRKXFVIEAGon 8ZYMQAdNlGXffh9GILyJTwQW8758V16tSUOtgQshJ6ZP9L6Dar6BzD6XnEIsFzBWXYyd JAUz/xb5hEUNJShO5HwUeh0KUEG4vCRweGm63QVL9QZBe73ZJYqD5d/XodjHMGj6iyON xWd6GMo2vGzXwq/x+mYf3vnUVRAu7wzC9pDy1f+0rWg4hRKA8Uvwmz5uAGhjI9PGvs5h tZ9w== 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; bh=zkfC4G5GEbPVk7Fi0u1Y9Nqd6ne5J0yoo6OmoGAaUvc=; b=o6PypUCxdg2xILwkdL5WlUeV85qCt4J2Gw8x8r/L3ROkYP2CcMxe9k1obB76WhduTC 4qRmprhpI0ZjfkfoZ2fitruLvmOPmi5w7KyRFqUPMW2fzwRbihRbdeIJRjhI2/HV9SjS /cyfLkeYhwNwg03QM8QGxY7Lzuiq8SSIDwygHAAh2OGK0lf9Guj+kzTg3fKV1HlUTtXk 45Xqy6wIZ9ruuufZvHKLL0H0Wh0jYLxLdq2krDEI0m1uYwhWuTJaQIxRKNjxRqwHSyah y5vA7xLf9zER03GbupeZIEnG895rTBY3t8F9/EaTL29oclXrKbZ/WQQp5JXSCcIT/PVg KMgg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si401326eja.285.2020.12.02.05.09.59; Wed, 02 Dec 2020 05:10:23 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730122AbgLBNHb (ORCPT + 99 others); Wed, 2 Dec 2020 08:07:31 -0500 Received: from foss.arm.com ([217.140.110.172]:38982 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbgLBNHa (ORCPT ); Wed, 2 Dec 2020 08:07:30 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 404CB30E; Wed, 2 Dec 2020 05:06:45 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.194.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0DF303F718; Wed, 2 Dec 2020 05:06:42 -0800 (PST) Date: Wed, 2 Dec 2020 13:06:40 +0000 From: Qais Yousef To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Catalin Marinas , Marc Zyngier , Greg Kroah-Hartman , Peter Zijlstra , Morten Rasmussen , Suren Baghdasaryan , Quentin Perret , Tejun Heo , Li Zefan , Johannes Weiner , Ingo Molnar , Juri Lelli , Vincent Guittot , kernel-team@android.com Subject: Re: [PATCH v4 07/14] sched: Introduce restrict_cpus_allowed_ptr() to limit task CPU affinity Message-ID: <20201202130640.zg2iijbnxzq2zhu3@e107158-lin.cambridge.arm.com> References: <20201124155039.13804-1-will@kernel.org> <20201124155039.13804-8-will@kernel.org> <20201127131916.ncoqmg62dselezyl@e107158-lin.cambridge.arm.com> <20201201165656.GE27783@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201201165656.GE27783@willie-the-truck> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/01/20 16:56, Will Deacon wrote: > 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. I guess task_rq_lock() always entails be prepared for surprises! Works for me. Thanks -- Qais Yousef