Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1308972rdb; Mon, 19 Feb 2024 10:44:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWEi67bpYMuEcbS5rZ9PvqbR3NYF7Dsj6VhT5LgAmLy/xHtVuCiHJny93blO1Mc7PP1/8AQwXXMeNTznEH+0QWrXd/VAtkcTHYRHX6W7Q== X-Google-Smtp-Source: AGHT+IGh3SAnKYTvI1mjQUM5KY6EucZtAaXUtTrRwa2Td9hR848DaDtUebNiO3YZROplVYUULalo X-Received: by 2002:a17:90a:5785:b0:299:11d0:4b0d with SMTP id g5-20020a17090a578500b0029911d04b0dmr10076386pji.27.1708368270248; Mon, 19 Feb 2024 10:44:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708368270; cv=pass; d=google.com; s=arc-20160816; b=NPoJIcRhdCGoeEgrfcI7TB1PY0Xt2b2MEU0FCGHEymVJSEJB39WE/0SYSM2QQCxMT7 nAUdS3521rb8FzK+oLX/o/u0MSo1Y3hA6vQConrG4AS4ldjEWzATEjn7fe3SZSQiG0A3 gGSwHlAQt3oeGp2v1oVOJq+Q8YWGuCYF2LU/hS1YOYqi2KZ2Z8d/fJVJxaQMI7KBwjoB 9tQTOPKb777EEmzOrYHfOwU34xTZMIvupDj4nwaV0ilID4Mne0uCiBa0Jb0SIOdnAKeN w4Kv+INk0ulpvpOkynBEh8Ace0eBFwJVkDQt7e/adfBGAKyp71zbwfGnvQEL5QSYG2VB PE0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=Dqt1BzLDOLT2qIOSaQyWM4Pf4xk5jdRIU3v5QNUeR8w=; fh=n4H4sG50U6DIdypz596/kRWdpMDl152Oh9U3Sp1nb/I=; b=CTeuvNJOZEYj5jB2tlhh04UxDNfqb7ZWBg6SjiYSjU0RhT0dCYRai1crfmrTNOT4GJ 3XqqEGRnVcTX/KEIwXZIeDAmhsNKR1BWS57iUQHiZx9Z1AhiS3HUzdELTBzFWI5eojsQ UqMy3nG9FcRNofgMhCkhrw6lILam8owptG5SPiBLcK/Di+aCEIECeZe/HIiwVd6l4e5B Z9YAJYaRbnmcx4WIJNfBBnkrO3IJEWzAjuTPB1yp2xqx/gGZ/qHBfKcUFyYeRHqeoq4m faqiO9GcMLKHVrQyuXhAYLDNZJPEbclxck/VZ7HAZqD0PC2qhSopvJR4RV8kK9c5YZKz V9UQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Nws6pBwP; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-71827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71827-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b12-20020a65668c000000b005dc72782fd6si4697345pgw.260.2024.02.19.10.44.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 10:44:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Nws6pBwP; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-71827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71827-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D664EB24422 for ; Mon, 19 Feb 2024 18:40:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3E56481CC; Mon, 19 Feb 2024 18:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Nws6pBwP"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wmkWlG3F" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20D7250278; Mon, 19 Feb 2024 18:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367858; cv=none; b=B0CvSuUs/k0kCDVotMg0T0MBPdwXCNkrFgpkN4ge7PCWL+QaRha2eHS4ZZSVX3bjU9nKR7Ud1jk4y6B/ntScTWPRifsh4s0dWCFQ2KRSDye2nbpHLTDs9Ft3j9Kz/qPaXr7leGcHnAhcAT+K0ybPscW9ApbIx3OTp+u4SqvMZBk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708367858; c=relaxed/simple; bh=VCcUjmWxYmFQHAAt7Z1tpW/3aeXFrz53ayAs/sfG3hU=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=kTaRwvS9J6z6QPYQPrgdd70//uiQY38E66cg79o8U/CLU7ieqZtN8YAtJ+mOmJq2F0ShDqrkxxpBhQvUYdcK3crzAKP/mMgFD1Djk93Khs4z6yryZeFVjBSLVLbcN/6hWJ1BWZHwI32GLrGd/nK83uzTE8in3JPOKDIqhL0Cc1E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Nws6pBwP; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=wmkWlG3F; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 19 Feb 2024 18:37:34 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708367855; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dqt1BzLDOLT2qIOSaQyWM4Pf4xk5jdRIU3v5QNUeR8w=; b=Nws6pBwPBnAJGnaXq5Mhv4WnUZcbWcoUgNOWqfTi4ABLSfbvbKTzi8g513sIjwbjfxCPkp i2rcvuKeh8n4WG7S7oOwdMHhLiZerOyy0NK+5unU5+jSL72Xy0U8i7R59vKVC5/avDPqTn P9T+ESU0rAFBbzR7XkENtmRQPjoPOSXSLIgv0+ukkWPo0MSLDWL33Ec7gG/mhAUSK1IDP5 SgnEbVez1lqgr5DtlVjc2Ov3zPtP9ezomkrFnlo27rkg0ScvAJvIpt8W3XVGliL/wiRqe2 lTXVDHe2Y9FVk6+m3njcp8wrH6NN86vA0AMwVG56yxuY1zrimII69lJPRd1B9Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708367855; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dqt1BzLDOLT2qIOSaQyWM4Pf4xk5jdRIU3v5QNUeR8w=; b=wmkWlG3FN8HRV0G5oH6sCrIAoX+9fjQSU5ZrCgJsnVEFL+9R1Kee0p9Vkr9ZWQOI1UMRP7 ZC8l/J+fkVV8uCBQ== From: "tip-bot2 for James Morse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Use __set_bit()/__clear_bit() instead of open coding Cc: James Morse , "Borislav Petkov (AMD)" , Shaopeng Tan , Reinette Chatre , Babu Moger , Peter Newman , Carl Worth , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240213184438.16675-10-james.morse@arm.com> References: <20240213184438.16675-10-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170836785480.398.10287268080200773656.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/cache branch of tip: Commit-ID: 5d920b6881f2249be3a028ce0a7f31c5cc61b1ee Gitweb: https://git.kernel.org/tip/5d920b6881f2249be3a028ce0a7f31c5cc61b1ee Author: James Morse AuthorDate: Tue, 13 Feb 2024 18:44:23 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 16 Feb 2024 19:18:31 +01:00 x86/resctrl: Use __set_bit()/__clear_bit() instead of open coding The resctrl CLOSID allocator uses a single 32bit word to track which CLOSID are free. The setting and clearing of bits is open coded. Convert the existing open coded bit manipulations of closid_free_map to use __set_bit() and friends. These don't need to be atomic as this list is protected by the mutex. Signed-off-by: James Morse Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger Tested-by: Shaopeng Tan Tested-by: Peter Newman Tested-by: Babu Moger Tested-by: Carl Worth # arm64 Link: https://lore.kernel.org/r/20240213184438.16675-10-james.morse@arm.com Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index dcffd1c..bc6e0f8 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -111,7 +111,7 @@ void rdt_staged_configs_clear(void) * - Our choices on how to configure each resource become progressively more * limited as the number of resources grows. */ -static int closid_free_map; +static unsigned long closid_free_map; static int closid_free_map_len; int closids_supported(void) @@ -130,8 +130,8 @@ static void closid_init(void) closid_free_map = BIT_MASK(rdt_min_closid) - 1; - /* CLOSID 0 is always reserved for the default group */ - closid_free_map &= ~1; + /* RESCTRL_RESERVED_CLOSID is always reserved for the default group */ + __clear_bit(RESCTRL_RESERVED_CLOSID, &closid_free_map); closid_free_map_len = rdt_min_closid; } @@ -139,17 +139,21 @@ static int closid_alloc(void) { u32 closid = ffs(closid_free_map); + lockdep_assert_held(&rdtgroup_mutex); + if (closid == 0) return -ENOSPC; closid--; - closid_free_map &= ~(1 << closid); + __clear_bit(closid, &closid_free_map); return closid; } void closid_free(int closid) { - closid_free_map |= 1 << closid; + lockdep_assert_held(&rdtgroup_mutex); + + __set_bit(closid, &closid_free_map); } /** @@ -161,7 +165,9 @@ void closid_free(int closid) */ static bool closid_allocated(unsigned int closid) { - return (closid_free_map & (1 << closid)) == 0; + lockdep_assert_held(&rdtgroup_mutex); + + return !test_bit(closid, &closid_free_map); } /**