From mboxrd@z Thu Jan 1 00:00:00 1970 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 1423EC433FE for ; Mon, 21 Nov 2022 12:38:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F84A8E0012; Mon, 21 Nov 2022 07:38:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A7FC8E000C; Mon, 21 Nov 2022 07:38:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64A548E0012; Mon, 21 Nov 2022 07:38:18 -0500 (EST) 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 586288E000C for ; Mon, 21 Nov 2022 07:38:18 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2419C1C6647 for ; Mon, 21 Nov 2022 12:38:18 +0000 (UTC) X-FDA: 80157402276.22.7823720 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by imf05.hostedemail.com (Postfix) with ESMTP id 6F68D100002 for ; Mon, 21 Nov 2022 12:38:17 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id C617D32007E8; Mon, 21 Nov 2022 07:38:14 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 21 Nov 2022 07:38:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1669034294; x=1669120694; bh=T8 0Ixd8IplxWaxxkiIeZY9gINSKEir9nQQHp4lWGxVk=; b=Y5faw+yRWPNOV2hnUX LASny6c2pOyCWupx2QWAxgQkAxVqhhNxzABiywBKZObmiB+J6cJKmH7554p/n73G bz3lUt+rsQPAxPUrrWvyIAIqoH3ffeo/mzRofAI+8QC+tFO8SgWyGnO5g0Y8NkVF Qu2udl3ngnON8skNwSsBA89mWXID86D+FZwDd3Jagr9EXFqBajbKoxfsbLq4FpA1 ZZULMMs9P76kG+o4spa+X0G3AiXwGjuWZUsFblBdTikjIdJcJ4TQHYmJBcGege5D 10JX5RDHHEUGWNO8fw7SXmiewcaX6a4fKOVwWRZ73qD2c2YUHRt4ZCZfLsk/9wEc FIQg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1669034294; x=1669120694; bh=T80Ixd8IplxWaxxkiIeZY9gINSKE ir9nQQHp4lWGxVk=; b=OYUC11qV0I2IrvHvHtUA0RSGB2/xDAkyKQGluEfCEfBw DJxF9up8rpG3ZAejxCGco7+x3UKYakTpf5Fsv8dXtCxkL3eFxnr+7BmuyRULph3D 6OuSc0/h4rwsaV9SJCx7zX6Iu8eZM2jElaHgO/f21rUwZw7tstUGxfgQbaMvmml4 B20IaTb9MNxyuAY9O6xs30C0jDi1Ka5X8V3q1tY/ipU7yyDspBZwWDHY2ZX4pZH3 go/esFGC0zDT01RiwJ7ZVNBF8/yu6uJ+/hTqw7rMFpzS+pFc0jg9P/HmhXfpedR0 qoJrhXTsLozMVsr6B8JpnkgQSHlz9UtiFK8l5wEYdA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrheeigdegudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttddttddttddvnecuhfhrohhmpedfmfhirhhi lhhlucetrdcuufhhuhhtvghmohhvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrdhnrg hmvgeqnecuggftrfgrthhtvghrnhephfeigefhtdefhedtfedthefghedutddvueehtedt tdehjeeukeejgeeuiedvkedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepkhhirhhilhhlsehshhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 21 Nov 2022 07:38:13 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id 2CC2B109A30; Mon, 21 Nov 2022 15:38:12 +0300 (+03) Date: Mon, 21 Nov 2022 15:38:12 +0300 From: "Kirill A. Shutemov" To: Hugh Dickins Cc: Andrew Morton , Yu Zhao , Linus Torvalds , Johannes Weiner , Matthew Wilcox , David Hildenbrand , Vlastimil Babka , Peter Xu , Yang Shi , John Hubbard , Mike Kravetz , Sidhartha Kumar , Muchun Song , Miaohe Lin , Naoya Horiguchi , Mina Almasry , James Houghton , Zach O'Keefe , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 1/3 fix] mm,thp,rmap: subpages_mapcount of PTE-mapped subpages: fix Message-ID: <20221121123812.4sxk7ewzfhdqq6zs@box.shutemov.name> References: <5f52de70-975-e94f-f141-543765736181@google.com> <78fa518-85b5-32c0-ee92-537fa46131f6@google.com> <759077a6-a08-5bb0-a0b6-53be2fe8b56a@google.com> <7a4f5e5e-de33-dace-c526-4a3d3cf5f6e0@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7a4f5e5e-de33-dace-c526-4a3d3cf5f6e0@google.com> ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm2 header.b=Y5faw+yR; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=OYUC11qV; spf=pass (imf05.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.24 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669034297; a=rsa-sha256; cv=none; b=zbH2FRnqMvbAdzoideaJ6fUEIjYFzpPosDYuX+P3WzpLNKinIGn9latwVNwyZtdqYAPyfw klXlfDU/aEurs23pMd8pG2GnuKVrnMtDvaA+t4DT7DINf29xRsTf6eaAw0CyH+25uNxrIF srZQnDqIh/YTMrWGcKOZ0EeKS1SFfA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669034297; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=T80Ixd8IplxWaxxkiIeZY9gINSKEir9nQQHp4lWGxVk=; b=1LSddTp3Hw3SNZ0/LtFygTXOmN8VlEiFTExYbrvI1hZt8z0RcgNCHwOKGogQuTko+p8zbz V46AUqDvhVlqg7WYr3cHsVMjQ1CulbgszMTCxqj1i9ilc7et4DNOAUJHPOJzVu0u8RLZ11 /gsuzHeG+7uErj6LOoxgzPNoXbjS0QI= X-Rspamd-Queue-Id: 6F68D100002 X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm2 header.b=Y5faw+yR; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=OYUC11qV; spf=pass (imf05.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.24 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-Rspamd-Server: rspam06 X-Stat-Signature: 546uww9fcu8uqauicsfayfgoboz9xmen X-HE-Tag: 1669034297-777147 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: On Fri, Nov 18, 2022 at 05:35:05PM -0800, Hugh Dickins wrote: > Yu Zhao reports compiler warning in page_add_anon_rmap(): > > mm/rmap.c:1236:13: warning: variable 'first' is used uninitialized > whenever 'if' condition is false [-Wsometimes-uninitialized] > } else if (PageTransHuge(page)) { > ^~~~~~~~~~~~~~~~~~~ > mm/rmap.c:1248:18: note: uninitialized use occurs here > VM_BUG_ON_PAGE(!first && (flags & RMAP_EXCLUSIVE), page); > ^~~~~ > > We do need to fix that, even though it's only uninitialized in an > impossible condition: I've chosen to initialize "first" true, to > minimize the BUGs it might then hit; but you could just as well > choose to initialize it false, to maximize the BUGs it might hit. > > Reported-by: Yu Zhao > Signed-off-by: Hugh Dickins > --- > mm/rmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/rmap.c b/mm/rmap.c > index 66be8cae640f..25b720d5ba17 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1281,7 +1281,7 @@ void page_add_anon_rmap(struct page *page, > struct compound_mapcounts mapcounts; > int nr = 0, nr_pmdmapped = 0; > bool compound = flags & RMAP_COMPOUND; > - bool first; > + bool first = true; > > if (unlikely(PageKsm(page))) > lock_page_memcg(page); Other option is to drop PageTransHuge() check that you already claim to be redundant. Or have else BUG() to catch cases where the helper called with compound=true on non-THP page. -- Kiryl Shutsemau / Kirill A. Shutemov