Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5919943rdb; Thu, 14 Dec 2023 03:40:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHg3dA1pqf79vJ0FmmP3UHpKqGP+Agyco3BRe4xpQz1nyxxiF9HryHV2uWts5xfEpOOerh X-Received: by 2002:a05:6a20:3d95:b0:191:c125:5e61 with SMTP id s21-20020a056a203d9500b00191c1255e61mr4022989pzi.9.1702554010320; Thu, 14 Dec 2023 03:40:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702554010; cv=none; d=google.com; s=arc-20160816; b=QSKm7PX1w6t64aL+UydIunl2AHgtMho/E8jqOoCkQMZIpa1MoI+e2YcCUNUEYVXv0C GSVaLyufIbcnrx467idbDTT3MMQznQj2P0WOIIdkRzwUshF1maIE6twSFbJh2OkZ4R2J wY6WUYhO+r/9TZbZYGzOP/soEvts+fg2FxVk4hDMGcJfzkz7IBkZZx/cKPVb6czpu1dB goDmCzg/DEUXuRe+rMRk7ylvKTjQZMeDF2MCebvQrAhzihFZD+/wer1LsaWmeVK9K1wj l1l99F+nDBGPhU6ihUc1gYK0davOzvkBLovqCF20F05ymSZkISc6KhFVPU6NZc7mBrok D62w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=zlyjqIGkkU16ioSuDTm/L9JQZA43R9ySqZ2sjllZ2p4=; fh=HBNJCb1O5m4cQgWGcwqoKY3KTbKsr5rANYvH6uVWzvA=; b=vpzeTp4e9wY96PXgLBELDUC3dFlbRETC0s5NIBrVjWAOiW64v6mQM65ZUNST0lzSuc EOsKQDXdb4T+gYhew3paytLWS/YR6tT6AP0A9t79gyszzlKjxHIR0Ua9XfINh4To4W41 FSkA8N5KU3Gxilt/BjkBZwHfB7ln40vsO7gjPeBEUVJb+b96fEjp0zUIeEtehyJDauLj 7lc0N0rpYqcAjp9R4iP9n23D7pq93mnQb3toHvzmAIjkD9KyDCrRdDNcP7cbhgHi0l+2 t9nIGA3mLdde5kYNYq9VfKxcsgruIHhLBcSbfyfDDBr9w2KbqoTSx+9wjE1yOZ0dhHTl lPDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 80-20020a630253000000b005b8ee1c0c68si11151161pgc.605.2023.12.14.03.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 03:40:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 33040802886F; Thu, 14 Dec 2023 03:40:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444095AbjLNLj6 (ORCPT + 99 others); Thu, 14 Dec 2023 06:39:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444101AbjLNLji (ORCPT ); Thu, 14 Dec 2023 06:39:38 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 484C11B2 for ; Thu, 14 Dec 2023 03:39:17 -0800 (PST) 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 972681576; Thu, 14 Dec 2023 03:40:02 -0800 (PST) Received: from [10.1.197.60] (eglon.cambridge.arm.com [10.1.197.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9BDC83F738; Thu, 14 Dec 2023 03:39:14 -0800 (PST) Message-ID: <1496407e-cf12-8192-5d58-aa02d903dafe@arm.com> Date: Thu, 14 Dec 2023 11:39:13 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v7 24/24] x86/resctrl: Separate arch and fs resctrl locks Content-Language: en-GB To: babu.moger@amd.com, 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, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com References: <20231025180345.28061-1-james.morse@arm.com> <20231025180345.28061-25-james.morse@arm.com> <9fae4348-7a1e-48ba-a5f4-c1b2ad3f0644@amd.com> From: James Morse In-Reply-To: <9fae4348-7a1e-48ba-a5f4-c1b2ad3f0644@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 14 Dec 2023 03:40:09 -0800 (PST) Hi Babu, On 09/11/2023 20:52, Moger, Babu wrote: > On 10/25/23 13:03, James Morse wrote: >> resctrl has one mutex that is taken by the architecture specific code, >> and the filesystem parts. The two interact via cpuhp, where the >> architecture code updates the domain list. Filesystem handlers that >> walk the domains list should not run concurrently with the cpuhp >> callback modifying the list. >> >> Exposing a lock from the filesystem code means the interface is not >> cleanly defined, and creates the possibility of cross-architecture >> lock ordering headaches. The interaction only exists so that certain >> filesystem paths are serialised against CPU hotplug. The CPU hotplug >> code already has a mechanism to do this using cpus_read_lock(). >> >> MPAM's monitors have an overflow interrupt, so it needs to be possible >> to walk the domains list in irq context. RCU is ideal for this, >> but some paths need to be able to sleep to allocate memory. >> >> Because resctrl_{on,off}line_cpu() take the rdtgroup_mutex as part >> of a cpuhp callback, cpus_read_lock() must always be taken first. >> rdtgroup_schemata_write() already does this. >> >> Most of the filesystem code's domain list walkers are currently >> protected by the rdtgroup_mutex taken in rdtgroup_kn_lock_live(). >> The exceptions are rdt_bit_usage_show() and the mon_config helpers >> which take the lock directly. >> >> Make the domain list protected by RCU. An architecture-specific >> lock prevents concurrent writers. rdt_bit_usage_show() could >> walk the domain list using RCU, but to keep all the filesystem >> operations the same, this is changed to call cpus_read_lock(). >> The mon_config helpers send multiple IPIs, take the cpus_read_lock() >> in these cases. >> >> The other filesystem list walkers need to be able to sleep. >> Add cpus_read_lock() to rdtgroup_kn_lock_live() so that the >> cpuhp callbacks can't be invoked when file system operations are >> occurring. >> >> Add lockdep_assert_cpus_held() in the cases where the >> rdtgroup_kn_lock_live() call isn't obvious. >> >> Resctrl's domain online/offline calls now need to take the >> rdtgroup_mutex themselves. > Reviewed-by: Babu Moger Thanks! James