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 53F04C36000 for ; Fri, 21 Mar 2025 15:19:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BCCE280002; Fri, 21 Mar 2025 11:19:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86BFD280001; Fri, 21 Mar 2025 11:19:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70E4D280002; Fri, 21 Mar 2025 11:19:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 52839280001 for ; Fri, 21 Mar 2025 11:19:17 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D5E6A120147 for ; Fri, 21 Mar 2025 15:19:17 +0000 (UTC) X-FDA: 83245916754.05.0652E42 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf19.hostedemail.com (Postfix) with ESMTP id 142DE1A0004 for ; Fri, 21 Mar 2025 15:19:14 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Np7eJ2aT; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="gm1/g1x2"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Np7eJ2aT; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="gm1/g1x2"; dmarc=none; spf=pass (imf19.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742570355; 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=6e8QHLGkiT1yWoOVvFUC84YvlHdbONjprG7kw5LGfqY=; b=5fGmjankfPru6FS86nPzWdY197wP74H7oo57QeSHb/6dp7jaP8Zer9ww+M5mb/L0MLWfiI BHEfQ52ziGWlwppUJmrDIbLqDLBcXRcyiQC1cDd7EhiO5hlZkYLZxE7zbtG1tD7JzSd3y1 W6BvbMACkFU2lsoo11hfSn0l1it4dNo= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Np7eJ2aT; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="gm1/g1x2"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Np7eJ2aT; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="gm1/g1x2"; dmarc=none; spf=pass (imf19.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742570355; a=rsa-sha256; cv=none; b=4xy4t7rn46Vo28K2kA7pkdoqVVfGKo1eCRlemJL3H6s+WhS3TShFfBR3kIaC+0Ax+pIygA o3+JkpHoYTrpYyIzy8VldZlzA/fw3f7ojE5Tofuw+1x5cv2uxhv0YlE7Gbq6AVGBAtj8nB hTZyge+yk/+1DAuTrgWn0golGj6EZyM= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 87E0421C75; Fri, 21 Mar 2025 15:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1742570353; h=from:from:reply-to: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; bh=6e8QHLGkiT1yWoOVvFUC84YvlHdbONjprG7kw5LGfqY=; b=Np7eJ2aTU+Opw6OCXC+3IgECpkDvvqiE1uYaYVTHQufEt9Cel2ZrhjfOszi7lxKi8jqBZW GQIWxV2PlIBGjpcXbW0W4H0AqYXQr0aHZRannqYbH63cmg/RV9z0YVKwF30o4JNDdwRLSi sKwPgCCt/yOSEI59NN0dir4SHsOx0i8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1742570353; h=from:from:reply-to: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; bh=6e8QHLGkiT1yWoOVvFUC84YvlHdbONjprG7kw5LGfqY=; b=gm1/g1x2gZ6KpSHZwGnR+8pkL5DS4aymaox/xd2YM0ylT/qXAztBxiDp6X8UOTYRVPl4ED 5KEEdRZFKwwbYoDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1742570353; h=from:from:reply-to: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; bh=6e8QHLGkiT1yWoOVvFUC84YvlHdbONjprG7kw5LGfqY=; b=Np7eJ2aTU+Opw6OCXC+3IgECpkDvvqiE1uYaYVTHQufEt9Cel2ZrhjfOszi7lxKi8jqBZW GQIWxV2PlIBGjpcXbW0W4H0AqYXQr0aHZRannqYbH63cmg/RV9z0YVKwF30o4JNDdwRLSi sKwPgCCt/yOSEI59NN0dir4SHsOx0i8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1742570353; h=from:from:reply-to: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; bh=6e8QHLGkiT1yWoOVvFUC84YvlHdbONjprG7kw5LGfqY=; b=gm1/g1x2gZ6KpSHZwGnR+8pkL5DS4aymaox/xd2YM0ylT/qXAztBxiDp6X8UOTYRVPl4ED 5KEEdRZFKwwbYoDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6FEA2139AA; Fri, 21 Mar 2025 15:19:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id yeT0GnGD3WfTEgAAD6G6ig (envelope-from ); Fri, 21 Mar 2025 15:19:13 +0000 Message-ID: <809792d8-8717-41d9-8dd8-ca91a5b54a28@suse.cz> Date: Fri, 21 Mar 2025 16:19:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] mm/debug: Fix parameter passed to page_mapcount_is_type() Content-Language: en-US To: Gavin Shan , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, david@redhat.com, linmiaohe@huawei.com, gehao@kylinos.cn, shan.gavin@gmail.com References: <20250321120222.1456770-1-gshan@redhat.com> <20250321120222.1456770-3-gshan@redhat.com> From: Vlastimil Babka In-Reply-To: <20250321120222.1456770-3-gshan@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 142DE1A0004 X-Stat-Signature: bemyz34r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yN+dFyna+MB04+47hkhtjb/5qzHiuXK3sC4PMVyLFfRA3xh5RCzInSBu1Q== 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: On 3/21/25 13:02, Gavin Shan wrote: > As the comments of page_mapcount_is_type() indicate, the parameter > passed to the function should be one more than page->_mapcount. > However, page->_mapcount is passed to the function by commit 4ffca5a96678 > ("mm: support only one page_type per page") where page_type_has_type() > is replaced by page_mapcount_is_type(), but the parameter isn't adjusted. > > Fix the parameter for page_mapcount_is_type() to be (page->__mapcount > + 1). Note that the issue doesn't cause any visible impacts due to the > safety gap introduced by PGTY_mapcount_underflow limit. > > Fixes: 4ffca5a96678 ("mm: support only one page_type per page") > Signed-off-by: Gavin Shan > Acked-by: David Hildenbrand Acked-by: Vlastimil Babka > --- > mm/debug.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/debug.c b/mm/debug.c > index 8d2acf432385..b6bd9555ec7b 100644 > --- a/mm/debug.c > +++ b/mm/debug.c > @@ -71,10 +71,10 @@ static void __dump_folio(struct folio *folio, struct page *page, > unsigned long pfn, unsigned long idx) > { > struct address_space *mapping = folio_mapping(folio); > - int mapcount = atomic_read(&page->_mapcount); > + int mapcount = atomic_read(&page->_mapcount) + 1; > char *type = ""; > > - mapcount = page_mapcount_is_type(mapcount) ? 0 : mapcount + 1; > + mapcount = page_mapcount_is_type(mapcount) ? 0 : mapcount; At this point it would be perhaps more obvious: if (page_mapcount_is_type(mapcount)) mapcount = 0; But doesn't matter much. > pr_warn("page: refcount:%d mapcount:%d mapping:%p index:%#lx pfn:%#lx\n", > folio_ref_count(folio), mapcount, mapping, > folio->index + idx, pfn);