Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2020216ybv; Fri, 21 Feb 2020 07:27:13 -0800 (PST) X-Google-Smtp-Source: APXvYqy30IyVrsQRz4T1FZHnKATTSCVO+PrVgYybsu/864tq7XLHgZOf1zne9rSmTd40TyiET9Q4 X-Received: by 2002:a05:6808:9ba:: with SMTP id e26mr2424970oig.81.1582298833623; Fri, 21 Feb 2020 07:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582298833; cv=none; d=google.com; s=arc-20160816; b=C/mzR112Ma/PeNAebJdytIv+6fAaHoERfKcJ/ehnK9TgUvaEAfWzE1jNGDBEJaIuj+ OjooZBddmTykL8OJh86P/FJ2RUe3rqYQjVnw5JrOsymEj/NES3HtW57hPDt9203VILZr roCJ4y8nwDCbiH46RiIJTF5w/Gj7pGauJbB8NcVKivjYxq95P8M/YBB6OC32jzTXyvII EqSMplf8tpNO8gKXs8SOoEZwLDOM55fMuVWzh+dg/4ZhLFHamq3PCw73kOrecFxTHSV8 Ketxc+h2ySzwLw7OBA28HPLB6+7BhCRUEsRXk1pRjo/oL3DefeutKKP7P4UQkvboaymi HbYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=RzGEB9pK6NtDTznlYzRWLJ3/7Px6CsIJAx3PEmjqBx0=; b=BFJ6O6rBbsHADuNq5rO3miRMP3azn/0yATmCi3NEDjFTwtWr2MuSJODKvE0dQKMRx1 10hkG4Jvg5HjB449C3icjI4kbVenOBR1YckRtDVwQP7oa3oL0vRaaq5cDW+e/gBxgicX qA1p8dOY8qzKQVoCuE4kWaEn2rPvZmFnYsKycsa1WS7z0izhOZWsYpTnLl1QnQyM+Lu0 7NOsqVuwAcdK6iunhiWe70wezza6qr0NywuBBNQtP/W3LUDYToD33fCFCW5VMtSal8bh aUS4wGboqjUBDPNx+EpIiavFfjsOwsbMesnkotey6KE6/gQp17h9w3jHBIy+BKLqwDx6 pu0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o13si1559696otp.27.2020.02.21.07.27.01; Fri, 21 Feb 2020 07:27:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729148AbgBUPZ0 (ORCPT + 99 others); Fri, 21 Feb 2020 10:25:26 -0500 Received: from foss.arm.com ([217.140.110.172]:41760 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728970AbgBUPZZ (ORCPT ); Fri, 21 Feb 2020 10:25:25 -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 205251FB; Fri, 21 Feb 2020 07:25:25 -0800 (PST) Received: from [10.1.196.105] (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1AB473F703; Fri, 21 Feb 2020 07:25:23 -0800 (PST) Subject: Re: [PATCH v2] x86/resctrl: Preserve CDP enable over cpuhp To: Reinette Chatre Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" References: <20200214181600.38779-1-james.morse@arm.com> <214c845b-d093-bafc-02d0-dfd810283f1a@intel.com> From: James Morse Message-ID: <32c563f9-c645-5c04-ed0b-18b3348c9c7f@arm.com> Date: Fri, 21 Feb 2020 15:25:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <214c845b-d093-bafc-02d0-dfd810283f1a@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Reinette, On 14/02/2020 19:24, Reinette Chatre wrote: > On 2/14/2020 10:16 AM, James Morse wrote: >> Resctrl assumes that all CPUs are online when the filesystem is >> mounted, and that CPUs remember their CDP-enabled state over CPU >> hotplug. >> >> This goes wrong when resctrl's CDP-enabled state changes while all >> the CPUs in a domain are offline. >> >> When a domain comes online, enable (or disable!) CDP to match resctrl's >> current setting. >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index 064e9ef44cd6..5967320a1951 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -1831,6 +1831,9 @@ static int set_cache_qos_cfg(int level, bool enable) >> struct rdt_domain *d; >> int cpu; >> >> + /* CDP state is restored during cpuhp, which takes this lock */ >> + lockdep_assert_held(&rdtgroup_mutex); >> + > > I think this hunk can be dropped. (1) The code path where this > annotation is added is not part of this fix. (2) The comment implies > that the taking of the mutex is something new/unique added in the CPU > hotplug path but that is not accurate since this mutex is also taken in > the only other existing call path of this snippet that is handling the > mounting of the filesystem. These things answer the question: "what stops rdt_domain_reconfigure_cdp() racing with set_cache_qos_cfg() on the mount path, causing the wrong value to be restored?". We can try and answer that in the commit message, or comments, but these will quickly be lost, stale, or wrong. These annotations serve as a comment, and let lockdep check its still true. (I think you can never have enough lockdep annotations!) > You do mention that these annotations is helpful for the MPAM work. Indeed, it splits up the, er, "big RDT mutex", these annotations mean lockdep catches me out if I do something wrong, and makes it very clear when changing something subtle. > Could the annotations instead be added as a separate patch forming part > of that work? Ideally these things are there from the beginning. Adding them over time as part of other reviewed patches works. I don't think adding them in one go before refactoring helps: you wouldn't have the confidence that they were correct in the first place. I'll drop these. >> if (level == RDT_RESOURCE_L3) >> update = l3_qos_cfg_update; >> else if (level == RDT_RESOURCE_L2) >> @@ -1859,6 +1862,21 @@ static int set_cache_qos_cfg(int level, bool enable) >> return 0; >> } >> >> +/* Restore the qos cfg state when a package comes online */ > > s/package/domain/? When, for example, considering L2 then "package" is > not the right term to use. Sure, Thanks, James