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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 78C9CC2BBCA for ; Wed, 16 Dec 2020 18:28:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2121B255D6 for ; Wed, 16 Dec 2020 18:28:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730685AbgLPS1p (ORCPT ); Wed, 16 Dec 2020 13:27:45 -0500 Received: from mga12.intel.com ([192.55.52.136]:49884 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730673AbgLPS1p (ORCPT ); Wed, 16 Dec 2020 13:27:45 -0500 IronPort-SDR: PmeavCPnRTxK/vQbrv3DsaHVo/60MyXfjWkxT3A6oKxQsoGZAiYysGUE6pdPZqY/m6BmrdO0dE OMQuHHsHW6/Q== X-IronPort-AV: E=McAfee;i="6000,8403,9837"; a="154345016" X-IronPort-AV: E=Sophos;i="5.78,425,1599548400"; d="scan'208";a="154345016" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2020 10:26:52 -0800 IronPort-SDR: 0egVT9fGEg6D6S2xHs+u+Qgvx5PmLBSDI9FG/0d9ataW0YhQqtdGDtoyTHMLEoxDeZ9Z4NK9Hp gfpOyAfRN/7Q== X-IronPort-AV: E=Sophos;i="5.78,425,1599548400"; d="scan'208";a="352711684" Received: from rchatre-mobl3.amr.corp.intel.com (HELO [10.209.155.249]) ([10.209.155.249]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2020 10:26:51 -0800 Subject: Re: [PATCH 2/3] x86/resctrl: Update PQR_ASSOC MSR synchronously when moving task to resource group To: Valentin Schneider Cc: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com, kuo-lang.tseng@intel.com, shakeelb@google.com, mingo@redhat.com, babu.moger@amd.com, james.morse@arm.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: From: Reinette Chatre Message-ID: Date: Wed, 16 Dec 2020 10:26:50 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Valentin, On 12/16/2020 9:41 AM, Valentin Schneider wrote: > > On 14/12/20 18:41, Reinette Chatre wrote: >>>> - return ret; >>>> + >>>> + /* >>>> + * By now, the task's closid and rmid are set. If the task is current >>>> + * on a CPU, the PQR_ASSOC MSR needs to be updated to make the resource >>>> + * group go into effect. If the task is not current, the MSR will be >>>> + * updated when the task is scheduled in. >>>> + */ >>>> + update_task_closid_rmid(tsk); >>> >>> We need the above writes to be compile-ordered before the IPI is sent. >>> There *is* a preempt_disable() down in smp_call_function_single() that >>> gives us the required barrier(), can we deem that sufficient or would we >>> want one before update_task_closid_rmid() for the sake of clarity? >>> >> >> Apologies, it is not clear to me why the preempt_disable() would be >> insufficient. If it is not then there may be a few other areas (where >> resctrl calls smp_call_function_xxx()) that needs to be re-evaluated. > > So that's part paranoia and part nonsense from my end - the contents of > smp_call() shouldn't matter here. > > If we distill the code to: > > tsk->closid = x; > > if (task_curr(tsk)) > smp_call(...); > > It is somewhat far fetched, but AFAICT this can be compiled as: > > if (task_curr(tsk)) > tsk->closid = x; > smp_call(...); > else > tsk->closid = x; > > IOW, there could be a sequence where the closid write is ordered *after* > the task_curr() read. Could you please elaborate why it would be an issue is the closid write is ordered after the task_curr() read? task_curr() does not depend on the closid. > With > > tsk->closid = x; > > barrier(); > > if (task_curr(tsk)) > smp_call(...); > > that explicitely cannot happen. > Reinette