From patchwork Thu Jun 6 20:36:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13688955 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 C6E8DC27C52 for ; Thu, 6 Jun 2024 20:36:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BD976B00A5; Thu, 6 Jun 2024 16:36:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F8666B00AA; Thu, 6 Jun 2024 16:36:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C1866B00AB; Thu, 6 Jun 2024 16:36:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E04C46B00A5 for ; Thu, 6 Jun 2024 16:36:33 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 98B78C1780 for ; Thu, 6 Jun 2024 20:36:33 +0000 (UTC) X-FDA: 82201621866.20.8047ECA Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by imf23.hostedemail.com (Postfix) with ESMTP id B83A3140011 for ; Thu, 6 Jun 2024 20:36:31 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=DPOwXyro; spf=pass (imf23.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717706192; 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=7a+uTIuCVLKYioOfhmkji191JEJPYvDHdI+sYE/KQAM=; b=epaBEdrHlXiysdDMiv3ISPqFj9VH31wyov2hP5qEjRnzXO/feoNynX9rzHG7gI2cleq/eC 1yKoQIfx3/ABFAvIktyeGVvvZJroF5kFHoZJJj2rJam3oP4+nouKGdpjbzguRYwJIbTMDI LWUdyXnbkBeqoWK3X7NMyhyK8r/4zBQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717706192; a=rsa-sha256; cv=none; b=qcsI7QkCVjnc6SXy2nJtmnyVCOaxq1J+98dhJrktZlbd/5kK5Sg/yIHvZPwf8PAOYVlDGi TWVRuNc2mfVNXSg7Y+LdTBH74GxfMc2CARbFWtk5FJdzFSxDyI6Zpd7rGAK8XaoYWeXbod boy2t/IcWfVsk0dogi1OKbcDNLsu2ZI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=DPOwXyro; spf=pass (imf23.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.152 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4VwGMH2CFQz9sjN; Thu, 6 Jun 2024 22:36:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1717706187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=7a+uTIuCVLKYioOfhmkji191JEJPYvDHdI+sYE/KQAM=; b=DPOwXyroOSaHbfjxX7deUekLF6Zh1Ir8FYzpm9YpSPot17FnGaMKsoTafpvY27N7a/qvSs wOD0MQVSMa0LjQbUScliFnlifr0D3jWjt3AqGS6ArslukjbRW0Or7rYVVBaAXcUugjJkSu x9+Egx1ck+zrr9c/fN6F1qPfVXrbuCnEOpFU0HPQestAtQ5J40zL3rxrDInZE+fQVJzVpE Qm+JKPRB1RPN1JlntC4UdN2af60m82v9D0RGS1UHEGbf/28movd4xZq+QBQp3aNu25MgNV whcnr2OwSQRMbZi8xUF9Mvo/xsWGsFzovbyeb7/Fkuw8kN4X7wdSLYtbXTSfAg== From: "Pankaj Raghav (Samsung)" To: Andrew Morton , Shuah Khan Cc: linux-mm@kvack.org, gost.dev@samsung.com, David Hildenbrand , willy@infradead.org, mcgrof@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Zi Yan , kernel@pankajraghav.com, Pankaj Raghav Subject: [PATCH v3] selftests/mm: use asm volatile to not optimize mmap read variable Date: Thu, 6 Jun 2024 20:36:19 +0000 Message-ID: <20240606203619.677276-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B83A3140011 X-Rspam-User: X-Stat-Signature: 6xxzyxhugj6pjqcxa87yn5twaxhwe7fs X-HE-Tag: 1717706191-141692 X-HE-Meta: U2FsdGVkX1/eG5IXoQhRNCDvulTTg0dTvIl1jL3swBYq6xO+UvdurdfaBEUYz9rXyXdE0pg3tuwutA6nMhwyHyQ23oo6pbXOPQpWFFAwMAiQvJlbjPPXKYDyp0lF2i9EIbekTTC0RT3ZLPc7QS9qXdm+JPowXq0kPKXkHBewoEpiWOnMhT42NdvW7KUG8vk5eF1l1J9TlHiBUFhEHhunFK0n+qGHfpNlGYQgYjGfXXVD//WONSjZ32kIjiPXs95eii9tP1iAeY7LhBOY8X+9lpP5HrEJu0xrlfvscRaBSOMxVUMs7GfF1gw+y0szfW509CDtOSagB4LpHw6rLGPwPOL9pr4fWUy5UffBaQt9fy/Iw+Dmz3XUjrlHEu8W1q796U0sIasqdPtWAGoRLMjSdP7/ZVjSyDCOMYeI+pvostni/+NaDMM0osEFScLgpRo9FnoGCUdBFRg6pKGSaO+4XWCRl9yKWbXvejCFKyyuO4IfcVnq32vi1sW1Ev6OARn7AHvqYen1Tqs8RxEnp6nHNeHROqcjTcp9XKksKI1v4ghBTKu2nxZRYzt/P44Af3g6BR4YyFfGYBCIku/g019qlzrt5rqwJzr8gigrdvTMhCWABvqPqx1r4u5MpuOkkmhQ2AuACit/jgJDG3XEZSMMMH2JWYw7hqQCgHS5xiVb5Qa46BKbEF8/jraQIKy+iwmYXYPS4N3V5iRZZHtoKsGnQSpo+5cdSs/Z+LpVN1oSa01mcWW8KQHEbRoidpzaGxp0W3pe2qlhU/h7C1YRdFNSAno2TeCCzljT2O0u1VXD4D1IxK6Mt7Gks1VSzfJZhstHo1l2GHNLstbROiRmj1i9RDkXOMzT1hepxNEz/uuMX368o/l0ZCD9q2P4wz7StGnwY664OXqhnxeUL+ZNjEkmjac8XctGrCtA54dk9m5QW8IqiMG5vgqWmOCqvLs+gkM8Ai561YC8n/DGSpiS9HD KXI0TWqO ltu/vqUeXMJJN5CFxYSN7t3EVJVfzeezSROB/shw/Gyfk0EBv/rLg1nX2EC5pNU+QJocBxP8jr/8w6ZlZHCvWKwLmmotPZue4jC3HShzSZ4lc36AD7rnY5fijeXtme4Qv5BQnls1xue3qFFrWrdQ6sHXiGEslbH5eBDZu/nleXhP4++f6ehR7jWIkRp1dzkh2FDbujw97iM+aZmM= 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: From: Pankaj Raghav create_pagecache_thp_and_fd() in split_huge_page_test.c used the variable dummy to perform mmap read. However, this test was skipped even on XFS which has large folio support. The issue was compiler (gcc 13.2.0) was optimizing out the dummy variable, therefore, not creating huge page in the page cache. Use asm volatile() trick to force the compiler not to optimize out the loop where we read from the mmaped addr. This is similar to what is being done in other tests (cow.c, etc) As the variable is now used in the asm statement, remove the unused attribute. Signed-off-by: Pankaj Raghav Acked-by: David Hildenbrand --- Changes since v2: - Use the asm volatile trick to force the compiler to not optimize the read into dummy variable. (David) tools/testing/selftests/mm/split_huge_page_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: d97496ca23a2d4ee80b7302849404859d9058bcd diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c index d3c7f5fb3e7b..e5e8dafc9d94 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -300,7 +300,7 @@ int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, int *fd, char **addr) { size_t i; - int __attribute__((unused)) dummy = 0; + int dummy = 0; srand(time(NULL)); @@ -341,6 +341,7 @@ int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, int *fd, for (size_t i = 0; i < fd_size; i++) dummy += *(*addr + i); + asm volatile("" : "+r" (dummy)); if (!check_huge_file(*addr, fd_size / pmd_pagesize, pmd_pagesize)) { ksft_print_msg("No large pagecache folio generated, please provide a filesystem supporting large folio\n");