Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1992700pxb; Fri, 22 Oct 2021 11:34:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+C58Dp9uqkHwwolOvmhzARXF117e4ORPp4Pz5pEp3dccJvET8qWygzVqSh9hC3a/lprpY X-Received: by 2002:a05:6a00:15c8:b0:44d:9f7e:ece2 with SMTP id o8-20020a056a0015c800b0044d9f7eece2mr1298708pfu.86.1634927646328; Fri, 22 Oct 2021 11:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634927646; cv=none; d=google.com; s=arc-20160816; b=mCej+NMQW2lXfxZ3iCH2utT4TdqOJnwDu9Z/N7lNBeHjbaWqgx49lQBtaQYlN3vgmV MhYsf4rzvMDeAPH1W6b6U140O1L6NoxK87tdrIoeAmYfrmxur/xarh4CI31rBoS4ndQc PnMjyIfBBwFj1H0/bqseqK8otFZt2F6XYM81YyEQbzJu+pdqWst5XizJFY1IEfHSWic1 3itOhfyNgDfE0ogZFF9ArSyfgqLcMCsZhOFZY5WtttUYzRMJ1mevn9FS8i2jlTecO1a1 s0882NJ8bYVSYtPD3UlHUVsITGSOpsVmShR/1GvaRns7wnDOWH0uwvhgsIrce8YmvRpz 5Olw== 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=NBhVpLar0txZPn9uW3/l2ntR4rDWu/IJoevVlDjZ1Wo=; b=RrVbazuhH6HEHBVctZwPzIpT5jq1E7Znmdecigztl62/9IcEGQayRyi+LQ+doiRL2N drTn9j3+UmAmSg8+zzQ6fszGcktc0RoQY/BfLkg5d0SV+zDaYjZTI+YU5XVG8fv3lFQe pCpsAGQODlzPnsADSFhdb+N1Fw7PLVIek5js/EZ07ZjrzNGb3Yoy0Yb20dX7R5GMa921 J+ry9ScmT3NHYVoE/rd+1U9d7kspbk8bIa772McTbwnsOHn594ydlavUGDmMv/GO/Hoj fXdeHogPj0zX5QL+ZP4aMyKGlUm3OhdLtCY2tYDR0t+ZQrhEBYtA2TUQx08NEL0GIxlF s3eQ== 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 r7si12496445pjp.186.2021.10.22.11.33.53; Fri, 22 Oct 2021 11:34:06 -0700 (PDT) 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 S233898AbhJVSck (ORCPT + 99 others); Fri, 22 Oct 2021 14:32:40 -0400 Received: from foss.arm.com ([217.140.110.172]:57634 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233685AbhJVSch (ORCPT ); Fri, 22 Oct 2021 14:32:37 -0400 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 98BE81474; Fri, 22 Oct 2021 11:30:19 -0700 (PDT) Received: from [10.1.196.28] (eglon.cambridge.arm.com [10.1.196.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6D66C3F73D; Fri, 22 Oct 2021 11:30:17 -0700 (PDT) Subject: Re: [PATCH v2 07/23] x86/resctrl: Add domain offline callback for resctrl work To: Babu Moger , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , shameerali.kolothum.thodi@huawei.com, Jamie Iles , D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com References: <20211001160302.31189-1-james.morse@arm.com> <20211001160302.31189-8-james.morse@arm.com> <47b1bfc9-1b31-d905-955d-638f3504778f@amd.com> From: James Morse Message-ID: Date: Fri, 22 Oct 2021 19:30:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <47b1bfc9-1b31-d905-955d-638f3504778f@amd.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 Babu, On 20/10/2021 00:19, Babu Moger wrote: > On 10/1/21 11:02 AM, James Morse wrote: >> Because domains are exposed to user-space via resctrl, the filesystem >> must update its state when CPU hotplug callbacks are triggered. >> >> Some of this work is common to any architecture that would support >> resctrl, but the work is tied up with the architecture code to >> free the memory. >> >> Move the monitor subdir removal and the cancelling of the mbm/limbo >> works into a new resctrl_offline_domain() call. These bits are not >> specific to the architecture. Grouping them in one function allows >> that code to be moved to /fs/ and re-used by another architecture. >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index 19691f9ab061..38670bb810cb 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -2499,14 +2499,12 @@ static int mon_addfile(struct kernfs_node *parent_kn, const char *name, >> * Remove all subdirectories of mon_data of ctrl_mon groups >> * and monitor groups with given domain id. >> */ >> -void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, unsigned int dom_id) >> +static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, >> + unsigned int dom_id) >> { >> struct rdtgroup *prgrp, *crgrp; >> char name[32]; >> - if (!r->mon_capable) >> - return; >> list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { >> sprintf(name, "mon_%s_%02d", r->name, dom_id); >> kernfs_remove_by_name(prgrp->mon.mon_data_kn, name); >> @@ -3233,6 +3231,39 @@ static int __init rdtgroup_setup_root(void) >> return ret; >> } >> >> +void resctrl_offline_domain(struct rdt_resource *r, struct rdt_domain *d) >> +{ >> + lockdep_assert_held(&rdtgroup_mutex); > > Is this really required? It documents that the caller must take the lock. Its not so clear how walking rdt_all_groups in rmdir_mondata_subdir_allrdtgrp() is safe now that the logic has moved to another file. (and these helpers will eventually move out to /fs/). Who takes what lock changes later in the tree, (after this series), these annotations make it a lot clearer that these functions are changing from caller-takes-the-lock to callee-takes-the-new-lock. Otherwise that patch would be much harder to review. >> + >> + if (!r->mon_capable) >> + return; > > I don't see the need for this check either. It moved up from rmdir_mondata_subdir_allrdtgrp(), quoted above. All of the work that moved from domain_remove_cpu() to resctrl_offline_domain() is about monitors. Sure, calling is_mbm_enabled(), is_llc_occupancy_enabled(), bitmap_free(NULL), and kfree(NULL) twice isn't harmful in this case, but its quicker to check the flag on the resource and return early if nothing else needs doing. Thanks, James