Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp458839lqt; Thu, 6 Jun 2024 08:29:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUhtp/lNvQv1i7AsC4g6hxtsngsLnBB3iZVYWQKNMRRbNT1XLplGGp/8kMRTBj5c0Dv93TQpb5J6tQbJTZov0PfO5S6+XyOuT4JCtx0lQ== X-Google-Smtp-Source: AGHT+IEBGbgBXlqmjAOqQVbVHS5W6V2cA0lz5kCpH/wmo+JFZmTt3IQz5hdQQAsGPQtfAhifLLTW X-Received: by 2002:a05:6214:3d89:b0:6af:cd16:e4ed with SMTP id 6a1803df08f44-6b030a4a1bemr68013606d6.36.1717687756851; Thu, 06 Jun 2024 08:29:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717687756; cv=pass; d=google.com; s=arc-20160816; b=Qohk6Y6dNu3SNhCgwBr8CgpP/9rv0KH80mGiEI2KjJINM5TQgYDjKjzhwEi4JyL9j3 sNbXlLbKI02UnOuyaB4OhSz4jR22vZnEyV3+8fwkBlIp5sHP7lKsma33Og5BwjC9Ukxi 21r8cFxjsmSbdG54ZERjjTZ2+ywetvNmFfs7Di6KJGow6OoxZYLrW4iDbE3aTgl5ITvt sAqLuXu9Po6yZiMMaOmoettNYfsYJqFOaJ7b2vX99L7kC/B9i59GkNInLjH2qUEwDn0k DZa+FgNLZ3uBuBzQSciHs9vYohY4RU4NphNAyJ48hvsZ2bbjneINnt5QRbSZfIBfrWhJ JIxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sHfJnp2lcftRA6X7UnUOG6z9rpZyMvNccJKHK19bpqc=; fh=+yTjJEMSoMUcNEeurfOb655c16l6PF89dEdLZzb4Ib0=; b=YDNqCQyMVYP9svv3Y0LM9Ke0Mou/GAEZgYm/bQrUvgG2QYiXjvA5wfullInusgSOkH YDCvRQsva8L01Jb170jKbPvJVplsq7Z/8fcfWPx5jgNJczbvbOE2iGSuUE+aW4OlHOSB HljWk8Dj/chhFvW4LvrH1kNyRy1o5z8wWyE3KgZ2ZQMv79qfl6bhn8ieCtz5z0FcIEQq Ipj59aXArFEj/8X+eOLeUOrqO8zDlylsH+CaLW5N5O2/fXXkjWvtwrrrehsDtYivoZ/c ZsXXxNHCd9TD6fDofGkgdMqek11mNlBgtuOkhMgCr4GLBJWT2+xMUb8LkOnpPrr/W0iG zF9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b="LvVi4t/Y"; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-204575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b04fa402fesi17792206d6.551.2024.06.06.08.29.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 08:29:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b="LvVi4t/Y"; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-204575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 79F681C219F9 for ; Thu, 6 Jun 2024 15:29:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FBB819645E; Thu, 6 Jun 2024 15:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="LvVi4t/Y" Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) (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 65E6113BAEB; Thu, 6 Jun 2024 15:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.161 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717687748; cv=none; b=BpAxkGeWCBGPJ24aHh6iWrsF9N0yJOp0i3xO6Zo/FCWSsjoAgCSDQgMyi35tbBrEXa/wjVItKEXoA+5oVXjNcmmocwIiGSzZmX14cPIcwt4cZK23Wl7lmiPOt5uQsV9D/AW/cfWG+CmYhhP3axxnlTJ2B1cQyHppnSGJ1vFH9tQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717687748; c=relaxed/simple; bh=vblmY0V4eAr6aMQr22rhxQQNFS3uYSQ222eApKlL8vg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=d3VCIvoSGTWlItEAuIvyXutild3nHKIRuQSLW4xHE8nb5+aNUkV/Ek6SDbGddKzQNhROLDz2u18Dy3EN8yBPq0/Ye9prEvgE/1JKc6a/eKMFso1pWzBtP8LNvuJklvYFLRQskGoALhO1z2ZfJkHtrW2/0Rb7AJtqwetKrbCKXUk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=LvVi4t/Y; arc=none smtp.client-ip=80.241.56.161 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (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-103.mailbox.org (Postfix) with ESMTPS id 4Vw7XZ2y3hz9sq3; Thu, 6 Jun 2024 17:29:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1717687742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sHfJnp2lcftRA6X7UnUOG6z9rpZyMvNccJKHK19bpqc=; b=LvVi4t/Y+JebtJu90GV9FYjqoscL8pKkggLe38PrTSDSMZo9hdjB+mAopTSegccbb4HViK jEdpQvAPqv0A7OTxY4mJHxa6rIxV84WwV0Z0Kz8+c77WOI4b/YjHXJO7pMTyDXgQoObxrb kfEUhB4NgDvh5fMKFbExU1LpjV1b87HsQIWbi/wGc/F8Q/gK1zWqx1Cw/sdZSB1vDpgkrs JtQ3wmsLWQUAF6MnNzqPV6dHjyyT4gZgacEAUHge2VlAgCRZVCePmiNOfl7FpyTn7hDPAq zyUoQots/+9NRT8V/GupLseBbSqcC1xTzeGRznKZtgALr5NyjtIUzAiQCYW01w== Date: Thu, 6 Jun 2024 15:28:58 +0000 From: "Pankaj Raghav (Samsung)" To: Matthew Wilcox Cc: Shuah Khan , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, gost.dev@samsung.com, mcgrof@kernel.org, linux-kselftest@vger.kernel.org, Zi Yan , Pankaj Raghav Subject: Re: [PATCH] selftests/mm: use volatile keyword to not optimize mmap read variable Message-ID: <20240606152858.hmtnmieyesv7o5i3@quentin> References: <20240606135835.600022-1-kernel@pankajraghav.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Jun 06, 2024 at 03:35:31PM +0100, Matthew Wilcox wrote: > On Thu, Jun 06, 2024 at 01:58:35PM +0000, Pankaj Raghav (Samsung) wrote: > > +++ 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; > > + volatile int __attribute__((unused)) dummy = 0; > > The mistake made by whoever wrote this test was making 'dummy' a stack > variable. That lets the compiler figure out that it's unused. If you > make it a top-level variable (not static) so the compiler can't tell > whether it's referenced by a different compilation unit, it can't make > that deduction. And you don't need the stupid attibute or volatile on it. I did cringe a little before adding the volatile keyword. While not a fan of global variables, that might be better than all these keywords. I will send a v2 right away! Thanks. -- Pankaj