Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2113737ybv; Fri, 21 Feb 2020 09:07:43 -0800 (PST) X-Google-Smtp-Source: APXvYqweMt4EqRwtJwT8QK6blWEuHHe24P4a4a0djURo4/GRa5JWkXROn17a6jpWB1h/P3ajVaTc X-Received: by 2002:a54:408f:: with SMTP id i15mr2737610oii.64.1582304863571; Fri, 21 Feb 2020 09:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582304863; cv=none; d=google.com; s=arc-20160816; b=wGCzANS84MIh8BFxyT1VR2TYG+oNej7FH+SnkbXcS18PjQHMKVh39c5//ccNzcpQzf v9RdL7GkJrfz8mFzzPM+dpBzLeXkNqiHlrsrS2EZrZIGCX8qMNKHzVVY4Tl0+tA2ZNgE Dh8iDhpHLRJit5IreUJZYAKfOoc2UPwU/bQzztUlUAE8p9pChA7YoEX1fNQ/zjxQU83m QvokWxBenfIn28JP/LDw8oq8ZP9HD+fVcmzG8OEmm0zU8Ixf0rXKz0W6Zss7fF79yt9v 9+2o2lzWGadHj78d6659sTZNVhSdZQNyE/eM7ZOUwl8iP8C1pf1TVEqMarxgVOG4EgpM hQNg== 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=yONG3UTA7uhT+8glgBapUEP31PrgQ0EzSt5mjclS1BA=; b=AimB2HVP2nvuzKfG3UdVldEnBMaHnmid5MB5CoZPV1YjlEriI2dgHu39nevbbuQBia vXXpt3sQ/G80IaRoCA1jp3qrSnenaa/bLpoYeRJuFR5xvlFPO14kX0wtynmJw9hm3oTc rc9nQoqGCgCuOYTwLCOY50TqFMfIOztnhqr1vy018lx29uS4Ok9VwVjMakjI8xGknWOK aVWnmSi+8wX7nRdxuPuaX4K6zzZMq/Bo3oKO2ardeoZMMR1iQRQHSmZtH7OWJ6Kepli5 2DUThD0g4JREpUPKeFQdcUJu3NLU24qCFcbd5ETyAgOq/RWa6WmZXm7FMXK8w5Isx61T joZQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j71si992850oib.213.2020.02.21.09.07.29; Fri, 21 Feb 2020 09:07:43 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728113AbgBURHB (ORCPT + 99 others); Fri, 21 Feb 2020 12:07:01 -0500 Received: from mga11.intel.com ([192.55.52.93]:21383 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbgBURHB (ORCPT ); Fri, 21 Feb 2020 12:07:01 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2020 09:06:44 -0800 X-IronPort-AV: E=Sophos;i="5.70,469,1574150400"; d="scan'208";a="229906480" Received: from unknown (HELO [10.24.14.134]) ([10.24.14.134]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Feb 2020 09:06:43 -0800 Subject: Re: [PATCH v2] x86/resctrl: Preserve CDP enable over cpuhp To: James Morse 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> <32c563f9-c645-5c04-ed0b-18b3348c9c7f@arm.com> From: Reinette Chatre Message-ID: <6e9f1a93-9665-6bef-7285-5f4de920471a@intel.com> Date: Fri, 21 Feb 2020 09:06:41 -0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <32c563f9-c645-5c04-ed0b-18b3348c9c7f@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi James, On 2/21/2020 7:25 AM, James Morse wrote: > 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!) I agree that lockdep annotations are valuable. My comment was specific to this one hunk, not all lockdep annotations in your patch. Please consider my comment in the spirit of patch guidance (per Documentation/process/submitting-patches.rst) noting that all logical changes should be in separate patches. This specific hunk is unrelated to the bug being fixed in this patch but can surely be done in a separate patch submitted together with this fix. >> 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. My comment was just specific to the one lockdep annotation added to an area that was unrelated to the bugfix. I noticed that you removed all annotations in your new version, that was not my intention. You could surely keep the lockdep annotation that is in the new code path introduced in this fix and a separate patch with the other lockdep annotation would also be welcome (with accurate comment). Thank you Reinette