Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4120355pxu; Wed, 9 Dec 2020 08:51:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjY6m7QLSIdTsVtUzWCPhigN1/s1SMForNYrlGlnaCPmodVrJlzpxs5uss10HWybVmloHs X-Received: by 2002:a17:906:8058:: with SMTP id x24mr2721918ejw.262.1607532676723; Wed, 09 Dec 2020 08:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607532676; cv=none; d=google.com; s=arc-20160816; b=MFLkMftNKsGiIXCo8XyJX+dqpMtRk3V9nfjWczDXnkRf5w3ENfDdjVXDr3faneyJjs Q4cKbOFsXCESfaDOzv5nW1IikUr+OGjheKp4oOVI3rGUVMcT3GKGcW8Xv5a/tWlsPhSo sezyjIHh9142PAp7+ioCiMF6vfEVUO7gIz5VSTPPjIJt7atngywWk10Bbf6uTC5WebBL c5+zSrQghhz4WJ1+j5jk/mNQY/rXIcHPG29H2Y7N8Ss1IBbNH+YKRZg9vLyWWIGMYTR/ oCR8xERQ8MOPjGir9APcHaQjLOkhyzrArvhrOM8cgTPiWn9ttohJ1QsmHRu825XTTOCv DmiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=niIV4K0/7K+yGdCb2w9KBuXcdwzvH80tJKHKpaZMcBg=; b=kBvOj3Ta5Re07iunJjuUd0n8Y54dowHjEFbLBuQyYFZHgrpvJBnBGsv5wEw7htLHD5 Ga5Ww3hGAEOUCsb/vYe5+WDLZuzYHhxB8HA+MbR/DnTHz0fVrDAE9wuSKZE698JlNRZ3 LTMze//HJ35NJZdiAkM8Tcaxv5p4Ds+zUkSPLRkUPN0PVcXB1GQi4WQLRrJKGfryT1gV V2qX75e750Bgp+seLXLnFd97n7003ktIh942smnnk1F2M3/g4OAVCwEnNV6EJGJhKnMw Eom3ablNBgdXbxfErSwpb30GaEwg4FH5Jd9ue4rsuQHebg7u6m991owa+nEflV0SJP3G 5D/g== 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 z14si1029730ejp.692.2020.12.09.08.50.52; Wed, 09 Dec 2020 08:51:16 -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 S1730364AbgLIQse (ORCPT + 99 others); Wed, 9 Dec 2020 11:48:34 -0500 Received: from foss.arm.com ([217.140.110.172]:37504 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbgLIQse (ORCPT ); Wed, 9 Dec 2020 11:48:34 -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 32E961FB; Wed, 9 Dec 2020 08:47:48 -0800 (PST) Received: from [192.168.2.21] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EBBB63F68F; Wed, 9 Dec 2020 08:47:45 -0800 (PST) Subject: Re: [PATCH 1/3] x86/resctrl: Move setting task's active CPU in a mask into helpers To: Reinette Chatre , fenghua.yu@intel.com Cc: tglx@linutronix.de, bp@alien8.de, tony.luck@intel.com, kuo-lang.tseng@intel.com, shakeelb@google.com, valentin.schneider@arm.com, mingo@redhat.com, babu.moger@amd.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <77973e75a10bf7ef9b33c664544667deee9e1a8e.1607036601.git.reinette.chatre@intel.com> From: James Morse Message-ID: Date: Wed, 9 Dec 2020 16:47:43 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <77973e75a10bf7ef9b33c664544667deee9e1a8e.1607036601.git.reinette.chatre@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Reinette, Fenghua, On 03/12/2020 23:25, Reinette Chatre wrote: > From: Fenghua Yu > > The code of setting the CPU on which a task is running in a CPU mask is > moved into a couple of helpers. The new helper task_on_cpu() will be > reused shortly. > diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c > index 6f4ca4bea625..68db7d2dec8f 100644 > --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c > +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c > @@ -525,6 +525,38 @@ static void rdtgroup_remove(struct rdtgroup *rdtgrp) > +#ifdef CONFIG_SMP (using IS_ENABLED(CONFIG_SMP) lets the compiler check all the code in one go, then dead-code-remove the stuff that will never happen... its also easier on the eye!) > +/* Get the CPU if the task is on it. */ > +static bool task_on_cpu(struct task_struct *t, int *cpu) > +{ > + /* > + * This is safe on x86 w/o barriers as the ordering of writing to > + * task_cpu() and t->on_cpu is reverse to the reading here. The > + * detection is inaccurate as tasks might move or schedule before > + * the smp function call takes place. In such a case the function > + * call is pointless, but there is no other side effect. > + */ > + if (t->on_cpu) { kernel/sched/core.c calls out that there can be two tasks on one CPU with this set. (grep astute) I think that means this series will falsely match the old task for a CPU while the scheduler is running, and IPI it unnecessarily. task_curr() is the helper that knows not to do this. > + *cpu = task_cpu(t); > + > + return true; > + } > + > + return false; > +} Thanks, James