Message ID | 20230620011719.155379-4-jhubbard@nvidia.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 1A93FEB64D9 for <linux-mm@archiver.kernel.org>; Tue, 20 Jun 2023 01:17:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D3038D0003; Mon, 19 Jun 2023 21:17:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6822F8D0002; Mon, 19 Jun 2023 21:17:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5230B8D0003; Mon, 19 Jun 2023 21:17:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 39C2B8D0001 for <linux-mm@kvack.org>; Mon, 19 Jun 2023 21:17:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0336C8050C for <linux-mm@kvack.org>; Tue, 20 Jun 2023 01:17:32 +0000 (UTC) X-FDA: 80921363586.06.1C57138 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2070.outbound.protection.outlook.com [40.107.92.70]) by imf16.hostedemail.com (Postfix) with ESMTP id DD2E1180014 for <linux-mm@kvack.org>; Tue, 20 Jun 2023 01:17:29 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="DuFfD3/+"; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf16.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.92.70 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687223850; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lQZhGUwkoU04C3ryaMpvsp8ELkjH/HHSIJHZlngWhEc=; b=nqoKAjLlV6vVzL+x7SstHTNmk3tNNRBk5t31eHrqllA/5Qsv27VN4EW1m53AyvDITg4bXC SXp3TPdSIDxI6PV/B/IP1j/cvGfJnQnQdM7+97cVwx/O42O+WJCCyrj4/ZwOhhEDp8Lu3q ONBZ7F5QVkHNGI7RCEx5VrTH9u5xF48= ARC-Authentication-Results: i=2; imf16.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="DuFfD3/+"; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf16.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.92.70 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1687223850; a=rsa-sha256; cv=pass; b=ItMT33j2Sx21TMMcYrna0vdMedonOWOfzCJuiykFQmSSMgehw1veZ+NZSuYkVzRBRx555u IAIBXV+uOKmSmWSqfngCIJBje99qDyqhMnL5cYFf++ADGe1MRb4h4Y6NN6mZA0q5eex9qA giDTGAfDeJdLmzdpAEg2tdbEskbtEds= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlvJv67lxOYFQcXQ1l/j1w2GdPy6UMW0Z747ygdko2qaam7M6UmkKmD2bPjUOhpUTVh1Gjb2ehFayqX7RH6ZNAsNr6g3U5kiRgnX4fbQp5JbLoEO53/vJx2JSdC9R78E1Mn6dKUr2HuTXtMNECOrwqX/lQUrjACfhM+7F3M0CDre9SIBJAp/prTdqctyNf5meYHUnfSET7BY5YE5JP9xV38aB1y8+YyQP35XySptwo+oeAqzsxU02SuHSBbNHMwrHmbQbGKi3x9Z07JE9Oj8llwLHczzzjRqeL5Wd9gfyfB6kht8p1X88XPIj2EcZWsvgv/YFi0ocvaiI/437Y6ayQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lQZhGUwkoU04C3ryaMpvsp8ELkjH/HHSIJHZlngWhEc=; b=fif1m3bUE2JzsfkjvuwZPzE/DpcJbA22WWXwovqKtuLSWZfGMFWTlYKwg6QXROyOjL720EuDZick404G5rrD1MDCzh741qRumv+JYXzXXx10BauWleodrIfxfd2fB5+9HmVEZkimXXG6AgpPn8mv4uKvP07VHomvKG+4qOWtNj35qpmJYfCfOa8kAFJ32tuPzYeI05PJIMzwxz7TGApUDzecFnmp3QX6Z6zjYNUkcmD65GwZtR8dLz6qQ0Bs7fl3YfoZuB/DcvNdrcKApNbOTrNXpcUB9B9ZP18DPkTxicr5+6WALs+vIAB3utrg/QeeGf8XvZfMpxjDbHDnJyKAgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lQZhGUwkoU04C3ryaMpvsp8ELkjH/HHSIJHZlngWhEc=; b=DuFfD3/+AK6g1xZB4WJ6v1rZk72ET9aSyc037210l3K4drrCZL2G8ID+qYWzWT7DqfTTf0/lvGYDNHZ1J/XxLYnKarM9FDSFpvWFMPxG/s5lvRBY6qfzal628OHxgUGVydJ2VITPpUbB3x7sSaWElfy7gLfUzSnILHk4in9DGHSr3/KB2R86XsrhBa0cMkqkpiO2r58KyhVPJKvzZIy/lXjwB2sKSM9JFtUcggD7JhwuQg9WhiAhhhZ5DpaRHhbKVWcWLq9i5LIGeiO032GhmCpnU51D5Mh/wYxbDEt4EwDbzqJG9A+rPaw1ysl+SzDSCERQi6iAo2zfVuivVvUExw== Received: from SA1PR02CA0007.namprd02.prod.outlook.com (2603:10b6:806:2cf::18) by MN2PR12MB4288.namprd12.prod.outlook.com (2603:10b6:208:1d2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Tue, 20 Jun 2023 01:17:27 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:806:2cf:cafe::ad) by SA1PR02CA0007.outlook.office365.com (2603:10b6:806:2cf::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Tue, 20 Jun 2023 01:17:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.17 via Frontend Transport; Tue, 20 Jun 2023 01:17:27 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 19 Jun 2023 18:17:21 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 19 Jun 2023 18:17:21 -0700 Received: from blueforge.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Mon, 19 Jun 2023 18:17:21 -0700 From: John Hubbard <jhubbard@nvidia.com> To: David Hildenbrand <david@redhat.com>, Oscar Salvador <osalvador@suse.de> CC: Andrew Morton <akpm@linux-foundation.org>, LKML <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com> Subject: [PATCH v2 02/11] selftests/mm: fix unused variable warnings in hugetlb-madvise.c, migration.c Date: Mon, 19 Jun 2023 18:17:10 -0700 Message-ID: <20230620011719.155379-4-jhubbard@nvidia.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230620011719.155379-1-jhubbard@nvidia.com> References: <20230620011719.155379-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|MN2PR12MB4288:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a834292-c643-4a9d-dceb-08db712c1caa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NyohEzqtaKpeQcuMKVUtYdyEL0NrUli5DUZW5KA/QcsRw3PjayjMpfi3Tk85Rzj5i7lsmDIegP2WV4IE6ymUoOh1sto4GqNWq2J8bYv87eysj3PH7rfgVjsv/AqaJmld2VpBXnUgfBIfmBM7I0VB7nxcfGNGGuZcGsM+hW65vVJ5EWCxmwvY7bPnAf9T91VKEldtDUc0/4qlomaF9vAwfyN2RZnPzzGPGZ/zjZcWFtxMPetjam6eaJV+8Qc+gGEbCDUsHBNkXJJsyTvh8e7TyuLJw9wjaoGS2kvJy0aDFSjCKKSaqlf2/E117rBC8dBfNIZSVRMKZWQfRXz8cRWOKkDz63NGY+XJ4bMA/jTWFfE2FyYzx6+4JZ43fKwKa4RkxtaVixL0ypeFcrDlawHxevlQ/GoytqH+1xfJ4BhYMV9B5xtIFvmgHfTQr0Dqk+fmjjdg97Dh61Wc0QBlHjXlRQ0B9PE51uacCUpbvlYVve/aavrSmI5IBoFpwKDMweyLVH2CMr7Z6l36L3QjRfg2p6u0AdBY5fqaigsPR59mk+Mstbg1+K3nnhJkGxNRvb/DLe4a3bJmryYX9ROnvU2j0UKAp8fmBAu/39ETWDgFqHuBbLJJNXA5minUAZ7rIqN0oNJP5ExJDgBJWJAUoH8QYl7JrHGTIN9WRrMWmyUXxjx0nHB1v5RtSkCWVJ9obdvK5cxJrUkJ2aNm5DayYE3afQ3LocMb5Ob4rzTO/e57WhJsQm2jsdeToCAUzmMr1izz X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(346002)(39860400002)(396003)(376002)(451199021)(46966006)(36840700001)(40470700004)(478600001)(336012)(83380400001)(426003)(47076005)(86362001)(6666004)(7696005)(7636003)(356005)(54906003)(70586007)(82740400003)(110136005)(316002)(70206006)(26005)(1076003)(4326008)(186003)(2616005)(8676002)(8936002)(5660300002)(2906002)(40460700003)(41300700001)(40480700001)(36756003)(36860700001)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2023 01:17:27.5266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a834292-c643-4a9d-dceb-08db712c1caa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4288 X-Rspamd-Queue-Id: DD2E1180014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 94ayz5wff74j6y93w6mmjwq5o3i3bhrc X-HE-Tag: 1687223849-783148 X-HE-Meta: U2FsdGVkX1/N2dTiwjPDcolmnefVS4+cvRfw7ifCDegMbr+ocLJpV9OYFtkTICIWpbqS+0q3THjvmCf0JTbdyOcWXnE+rk6bCer53NB1yLhUWeubWFp96HTu/UpIteJ6K6JqXxtZRCa5rYZG8/s/OpgIKXM3OkK6677vQDTTc/VPFHxdAiD0DDuDXPk8T2aLguPCXQux7QYDfKiVQZ9MEVaW8og8GmqGOAyYWk9z9LzhjanolSjO7CMNF8vknoRRv9rHnuoTVGXg3nVTWeDNl5AXkT3/edvZRym38B/dzoipEjuAoUJifvfjVdGw/KBA2cHUp9UXImpkhs/rHFxxTJoATUZWmQnkAK5H5EnnzFBDT8KvRPV+0nquXGjZeC2uvzR5/sRL7DS9eME1ftbwOgPbS1BYYpdLrJ3ltEDnq0BguCW02nFODxk6pkUAp9BDOniUjRDUQWSdiA/3lP1tYLJsbJV+Zabu2yit2VrJOHNUmdv3mJwh1svtTBCXf64Py/c+zZmtlwNBJtQ0xRBeq2OJXZH1c2DubQO91BIt6veahMOmE8BJZu5105Z+C8Z8TYePFvLIFJa6FkJx0mfHwdwf1ErYKg1rC2A3c88yxAEuSRmRq9jYckD6OMNYTiZFZWtW7PoDj/kXVDSFQdDOm9xpgtcQri6GdZQAXcQQ8LneRoSSagKglOSzBQXC+mYb2kgfuagmkIG9gVdip3Ku/1W6KGVF0O7w5077c66MAt8JHDun5QHV4+9R9aF5Fb+bl1nZrcR24wTg93DHIdF3xLG64BOTlGmn9ypm3WoD6XXi3hT2OiCvDTS07ZSEsrv8ZxFhV2uDHGx3atUf1Z+0SBsDHyROb3cfHunz/auSMppjN/WtNuLL+EmZBHAYpE0W9CmBrqXSysKQXgiM0BAiWnnMz6nErWilRpWy5uQLTkYkRgM41/wP5JSxunnugu7Zr3iPMSwt2TVDmOV+SgN jkqpWSvu KoXS0imdbLybITrcMnGrKAiEqKpSp24X3oprbNuKhS3VNxfgyLYC2jVy2A5UZ13Fxw5uXPGmbL4ryVGouZT6uUZ3J7BXDM4U2/cjj2IH4eDUGIJ38my/dKiBOnOzw/M5Gtq61W+3D4EyVsau88S6WOOxnrOnnpyL6dkpBbxr0Gj2bq3YNczJlhAq/kEsNiu8Hy7MDA0+fo86nFubism2Siq42ozn5QdmZX3z/e6z4nWxADSxUKGbu0VLExOLI2nHlmHU/QnK8IM7lIAk= 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: <linux-mm.kvack.org> |
Series |
[v2,01/11] selftests/mm: fix uffd-stress unused function warning
|
expand
|
diff --git a/tools/testing/selftests/mm/hugetlb-madvise.c b/tools/testing/selftests/mm/hugetlb-madvise.c index 28426e30d9bc..d55322df4b73 100644 --- a/tools/testing/selftests/mm/hugetlb-madvise.c +++ b/tools/testing/selftests/mm/hugetlb-madvise.c @@ -65,11 +65,15 @@ void write_fault_pages(void *addr, unsigned long nr_pages) void read_fault_pages(void *addr, unsigned long nr_pages) { - unsigned long dummy = 0; + volatile unsigned long dummy = 0; unsigned long i; - for (i = 0; i < nr_pages; i++) + for (i = 0; i < nr_pages; i++) { dummy += *((unsigned long *)(addr + (i * huge_page_size))); + + /* Prevent the compiler from optimizing out the entire loop: */ + asm volatile("" : "+r" (dummy)); + } } int main(int argc, char **argv) diff --git a/tools/testing/selftests/mm/migration.c b/tools/testing/selftests/mm/migration.c index 1cec8425e3ca..379581567f27 100644 --- a/tools/testing/selftests/mm/migration.c +++ b/tools/testing/selftests/mm/migration.c @@ -95,12 +95,15 @@ int migrate(uint64_t *ptr, int n1, int n2) void *access_mem(void *ptr) { - uint64_t y = 0; + volatile uint64_t y = 0; volatile uint64_t *x = ptr; while (1) { pthread_testcancel(); y += *x; + + /* Prevent the compiler from optimizing out the writes to y: */ + asm volatile("" : "+r" (y)); } return NULL;
Dummy variables are required in order to make these two (similar) routines work, so in both cases, declare the variables as volatile in order to avoid the clang compiler warning. Furthermore, in order to ensure that each test actually does what is intended, add an asm volatile invocation (thanks to David Hildenbrand for the suggestion), with a clarifying comment so that it survives future maintenance. Cc: David Hildenbrand <david@redhat.com> Cc: Peter Xu <peterx@redhat.com> Signed-off-by: John Hubbard <jhubbard@nvidia.com> --- tools/testing/selftests/mm/hugetlb-madvise.c | 8 ++++++-- tools/testing/selftests/mm/migration.c | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-)