From patchwork Wed Aug 28 16:07:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mateusz Guzik X-Patchwork-Id: 13781579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11250C54E65 for ; Wed, 28 Aug 2024 16:07:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6872A6B007B; Wed, 28 Aug 2024 12:07:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 610046B0082; Wed, 28 Aug 2024 12:07:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 489696B0083; Wed, 28 Aug 2024 12:07:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 274206B007B for ; Wed, 28 Aug 2024 12:07:18 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1C5F51402C5 for ; Wed, 28 Aug 2024 16:07:17 +0000 (UTC) X-FDA: 82502133714.18.FDDA71F Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by imf06.hostedemail.com (Postfix) with ESMTP id A869118000B for ; Wed, 28 Aug 2024 16:07:14 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CxogMkzT; spf=pass (imf06.hostedemail.com: domain of mjguzik@gmail.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724861146; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=zbU2BXq1tnO79gtv2UE1RsIiJczZ+KcvBGQej5bOV3o=; b=358Xj3hJeLZ7xNHzw9D6fi3SVSu1tWmYwNqcTRzwfvrBmMLAQcJmU5lc5RxGnkGav27yj/ LnYsVPqQhwfrGVhr96tlKfmbU2qYQbuqvR3M4LY+h27F5pzyf2gnz6kXUQ/YtHfHZM6jb3 fKqt1O9mzyJhlBzls8i97NWD1BktKbY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724861146; a=rsa-sha256; cv=none; b=V70ExEjJ7FWNTLy1OQQncquYOOGoeEjSPOjeGP/brYgGWsRPrdnRK/S0IJ4Uq+0QteoqUt fys8ytxy0Q2EXwDR4y0/VRBaXSilqX7RuNj+xyODzQkwxNUZzS/N3dEXlANDWbul0RuIOp vrQJXcKMIQfZkEzsPjdZA3OBLfoUHdY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CxogMkzT; spf=pass (imf06.hostedemail.com: domain of mjguzik@gmail.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=mjguzik@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-428ec6c190eso60898835e9.1 for ; Wed, 28 Aug 2024 09:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724861233; x=1725466033; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zbU2BXq1tnO79gtv2UE1RsIiJczZ+KcvBGQej5bOV3o=; b=CxogMkzTLvvnJBpaVHPYeL+UORPfH44a6wwYnZ09NYn19yYrjVSCHxt5prpJJAyIl4 Jdb8f5Qi/3r910+2T/8HHcvTFtX5ZKRXrrx73Rg7HEXuYer9xkAIp/K9LR2wLGzaV7kK tkmrcQHmMdGx4vto2Jutcq5MkEZAdOFInBQNNNLBXGR3AAAoOXdav3f92+BFjmNC46Le PUazcpVxu4Sy9JP4vx3vxv6oFg6KccqblU2UFJmfcszNycnE9vEnEbwyfOVgSFfEDINH wx7GNxt1AV73jdmVp8wISLy/y/L/gN2ZfWxkl2CkMXFaLZb/O9OBbmlZ4m7MV0E0dcOR 6sIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724861233; x=1725466033; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zbU2BXq1tnO79gtv2UE1RsIiJczZ+KcvBGQej5bOV3o=; b=azaWjY5DCanPEfM/P50smSVb62pzV0vFXfONtLHvnmdzNY3KIZJ2r5IdX096OZ+fkg TtM+xBOzNVGtUkEs9vHyqJIKx4LG7almqRAYvTXtR97bfWh0Z1SDFvF9YsQDg//C4/KA h9VvF506lFlYHh5cdM63ZFn5Pyl3UJz7qKs3b5elHLJyTxod9TkfIHiyC/AennGMjYQp Hh1cLh2kstk2G1CibVCpsuPUR7quTpVuyxoc0FO83l8vZJtFyY4rRB3jD7TBPjMRx4rS EwIcy+nXeVsmS8qP8cvXNGpYVd2xsR1jCN803lgj7RRz67Z9DRLhKfpI6keuUqA5Kn13 5zUQ== X-Forwarded-Encrypted: i=1; AJvYcCVTtGJptS+nqorlwJYWf7voi/MNfqTMXhhqjZXHbZF7hqCOs2tYH3msgkwEU1f4o867p3GJfd63Eg==@kvack.org X-Gm-Message-State: AOJu0YyKX8gL530ykqH3CV1z/nvo2kzqiPNmEv+AqKy6eu3gf2lVtcb1 PrZ/EuLbkANQKoYhxxXkUJoQfcMERbQGVARhfAtlMHzDrm6QjkTormxGFQ== X-Google-Smtp-Source: AGHT+IFteIv+aolP5lnxf71eCn1tlHkqiGzGQK6pUQ8+qbIIZfyL0r3ZwDrw7p4y6iw4futlBlj46Q== X-Received: by 2002:a05:600c:4586:b0:42a:b62c:8c86 with SMTP id 5b1f17b1804b1-42bb02f95b6mr1077395e9.32.1724861232380; Wed, 28 Aug 2024 09:07:12 -0700 (PDT) Received: from f.. (cst-prg-86-203.cust.vodafone.cz. [46.135.86.203]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3749b22db16sm157598f8f.5.2024.08.28.09.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 09:07:11 -0700 (PDT) From: Mateusz Guzik To: muchun.song@linux.dev, akpm@linux-foundation.org Cc: dave@stgolabs.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mateusz Guzik Subject: [PATCH] mm/hugetlb: sort out global lock annotations Date: Wed, 28 Aug 2024 18:07:04 +0200 Message-ID: <20240828160704.1425767-1-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Stat-Signature: m1o45d4duz45bzdua1fk8iccnc5phe4m X-Rspamd-Queue-Id: A869118000B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724861234-108831 X-HE-Meta: U2FsdGVkX18tyjKcZJjO3495RHKIgTgZzFbyheq5XopFTeWgxy0Txy4jn9Eb57m1P04mmmLcOy8r7nTE7nyGyshOxT6EAn0KYNKmoFJrQqzkw+vIIVsg0lBOo3+olxiIohCtIMy1B6hd+z3WtL66pSZATqUCH1A8h9drtHrLODq0UxrTqaLggCImLtyXu5noY+SzXNOuK32F+MUrBu4PwDQVU2bNw+GDqgWe4ZIRGXAbsAOhe3B+NsVkFxI9d4jqazrbF658h4DNCuC6hGYXIfLEbGNKQtb1qZHh2A2vNycANZHqjaRalC3ycu/FyLWjWnjbK23ueRqyGJ3+sMRLT26Rj22Okyle6UlT2aKLfU/H2g8JCxipdumlCBQ9/Pyc4ALkE3t5D4Om6rW8Y9QBq4FEpsV87/PKE/6kEdQE7aui7/Zf4fnNkBIvKElcvsdtXawzztyqDMeIUL6ioI91yMfN4vmClpf3vBEXODnb8roPK+uYnz4WaJBAN30WPX1caunBasuhOkD0lRwxAOjF+KfvkgXTRFi+dOIdbGkp4Qyw3dkn0EVH/QM01PJeDTvwqre5qXYCe7vJVut/tRq+5cG1S7WSXsD0t8SX43sbkxB/vogZyzIX1PyS6f3HSUhPUlO2j+Akzq3+iWvHutSezrLXKusjpzKD+FqvR35meliZMBpfYEWK0Tju+gdVFwRlSNC3gWS3uXjamrWO55P+vgzKunCojH9htLuQLtSHPJKEuMcoaemfdknUMzwruP8GJjRKZ1OcN99cs5u1dlzIaZlddPtDXpqdc2meVJbNNzgcAc0oq5pfaM7ZQtfSkNLCsqZeH3443G0ho+apASiyzjuUfnCwAJL5kq32CU+8cVIg+CCRyVSLm7vHyfcqqU5gmwuSH4nCbLuR2A8FyTzu/GndFjs+htbauLPyS+mLkXWOzg1G8wVLImRDgmV9dfQz+lQnvjPyhkfOumjUljW JVAkVC1L TjEoyp+ljYBK0roUUE7FycqD1Q+1rY19aKSUxwuycUzvYJhHgo3qta/nR4l3XTm3Hb95Q1EHoqdGPmR/514p4X/T50sKhf+s02OMWlHMizLs4MYkfEE5dInM/WQsSyERD590VIji8vbokGxyyYsBDJGttKFyYbBBtELmyWhfwc6RNXh0Ypce753cos3bUcho9nrj6kytxL4KyNYNVjeKHBsW0ioQhFRzjfZN5Ohyhr4guofNibFXpO7p/5iM/BJHlKKAvXq+w81Huw/3wfAWuZHl1blgL3xVk5wKXCcPOxkZ5oz6xvnkWtcBxfJKhOiZ6RmIHFtYNuhrXmWXxq3ujR+EwJgFqicAq7NI2cT+/4/UeBvOnAycac0a2KQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The mutex array pointer shares a cacheline with the spinlock: ffffffff84187480 B hugetlb_fault_mutex_table ffffffff84187488 B hugetlb_lock This is because the former is annotated with a macro forcing cacheline alignment. I suspect it was meant to be the variant which on top of it makes sure the object does not share the cacheline with anyone. Since array pointer itself is de facto read-only such an annotation does not make sense there anyway. Instead mark it __ro_after_init along with the size var. Do however move the spinlock out of the way. Signed-off-by: Mateusz Guzik --- I did not benchmark any of it, looks like basic sanity to me. This came up as a side effect of an unrelated discussion. mm/hugetlb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 4461d27f7453..1a833f016847 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -72,14 +72,14 @@ static unsigned int default_hugepages_in_node[MAX_NUMNODES] __initdata; * Protects updates to hugepage_freelists, hugepage_activelist, nr_huge_pages, * free_huge_pages, and surplus_huge_pages. */ -DEFINE_SPINLOCK(hugetlb_lock); +__cacheline_aligned_in_smp DEFINE_SPINLOCK(hugetlb_lock); /* * Serializes faults on the same logical page. This is used to * prevent spurious OOMs when the hugepage pool is fully utilized. */ -static int num_fault_mutexes; -struct mutex *hugetlb_fault_mutex_table ____cacheline_aligned_in_smp; +static __ro_after_init int num_fault_mutexes; +__ro_after_init struct mutex *hugetlb_fault_mutex_table; /* Forward declaration */ static int hugetlb_acct_memory(struct hstate *h, long delta);