Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp533224lqt; Thu, 6 Jun 2024 10:21:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfphyr8FBrIsLfsRe6c+kkxHUSY7rnQQGU+6ORjGgbptDyzxVvqvQHh9r97fEk4jieXnue+h4YYjifSI/sxVhSgD2/CycGxIENaHtfSA== X-Google-Smtp-Source: AGHT+IEWrcAvBWhuR7WrSWI0zq2uQG2TFc3+FrsxKFx/ShZ7AgTNsTOc1Gv4z+TNaY5J1NU9no+s X-Received: by 2002:a05:6e02:b48:b0:374:9fd2:79a1 with SMTP id e9e14a558f8ab-375803c12a7mr3749955ab.28.1717694516136; Thu, 06 Jun 2024 10:21:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717694516; cv=pass; d=google.com; s=arc-20160816; b=Myq6mO1li4YMvd2p/wQKqg+tpJasbhxDFLSBXiH5SlNBNlFVo3lsQqakD5ZpOXv9LB pyojzM0x+HU6CDDyFVybR9LlcSHf9c72GuwImGc55XKSpQias9duPQnlXyuic/SDrb4M ZwHBmkVWyVqsSzcta1YcL++6JPRhXxT6bgK2KkkpVdwwn9TVagDbe9uCMzG0LKOYv1Dp 58Wc+VMdDXzO0PaFheRCaJsqQrfUp8WdKfzWoQqrODuL+SLQtlggd9g4Txe46tYDE4tT D3hlKBLLumH53A6xdWPN/447g6QLpW9mhnO+pZTIzEy0KdjFC6mHemLrj+MMCp6Bbg9J qi2Q== 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=uRrb0Shq20IiSNENDDmGhgfsdkWEm9jjuSCuCC1VoMw=; fh=ev+33eag19F/06lkGnxT89ptTkfrle2iJuK0wJ0Kqv4=; b=kPkzg6oYjz+FRt1I77O49DPJ724fDnt3nf6ABNHp3r6x01JTYDyvUq66WKuOgARzaH YD7w8eAp3eGr+eup0a0wK92H8qsK7zM7Rru3i471DOb4Yfpp1ppMkrFkI0jy4FhRQOOb MHBICPHlrK2psT0P7caYFovyPdvVPonaYTMHy20slF0Jqu0+U3k/k2XSSHsTnzw/ThVZ QWLP4Le6yGsFrtZ7/7XMcoqAF9ynwf1TFI6kzh97/4kKgrLHZlZ48pmOFq1xCkfsXTK8 4jecPMsmCc5nnH5rdoYUHLdXlwMgD0P8bOMuRciWRy9qYe/XKbBim5o100ZsMMj6kKl/ x5OQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=B4cxWexY; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-204483-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204483-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de27609acasi1455863a12.532.2024.06.06.10.21.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 10:21:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204483-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=B4cxWexY; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-204483-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204483-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 741FE28CE0A for ; Thu, 6 Jun 2024 14:59:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67415198E71; Thu, 6 Jun 2024 14:35:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="B4cxWexY" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 98EF713BAEB; Thu, 6 Jun 2024 14:35:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717684539; cv=none; b=k6wAP7ZOPNeKl0AlPds7NyyF3XQiH8LooqeXiyqs/WpN0bkB9knNi/JZd9xrocgpjhmhfP/2qIn7ItQRRsmWo39fgCqEOsnfj0iFmM2NL8IqxqXdMLLyQJlpQvvcqmIjx86aZjpmCxqoVRI2f+JGLtuwJyuk8Jvlj2geW2kF0F4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717684539; c=relaxed/simple; bh=BT2gIZwJSo+mPsjm84uN4o9TRUKDukMweCkYFWP+9bM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LyZsu6A6vKelXOI/1ynYVpc6fikyH9lPSFw6C8doezAf4gpYchPrGckQTMotEKY6jiY/ZNcH3xcafVi5pCpxRmDmh9vhmPd0XUVL2HmVqLRr3bwYyWE0Up+mz2HBrebEvOYUKPLc0DtcSeYEKnA6tuDpMWK9bYpx2xs1dw3gSQY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=B4cxWexY; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uRrb0Shq20IiSNENDDmGhgfsdkWEm9jjuSCuCC1VoMw=; b=B4cxWexYSYlbRcxFS0XQxf0b5b QEa7Y8Fza7o3qa5Dc/k3zY6cZhopQe29udNpbF0A6IuKXyxtpQz2N+X/hm2xyW2jB9qsqUpNmaCnj Q6A71cWkdXwUzaVEKwkm9eA+7JX0tmc/RnhCy3uqES3w74tiZcAAMiIN7CEvB4Lbj9wCKcYtHFqVu ji/Tt5LvOQ7LQ/oSkeHsPl8o0CeevQ/lrFj6AnljM7/Xdp2ygiFXIQ1BW6PdsaT3gOBIWfFtyTBKi 2435vzdX1A23Lj/xHJw6diCsUd5RPmbN7etRz1d6GLFj2+lfQNXc46P3LV5uExPEqNuPAKQQ0TE3+ /jNXdOsQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFEDD-00000000658-3ikm; Thu, 06 Jun 2024 14:35:31 +0000 Date: Thu, 6 Jun 2024 15:35:31 +0100 From: Matthew Wilcox To: "Pankaj Raghav (Samsung)" 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: 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: <20240606135835.600022-1-kernel@pankajraghav.com> 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.