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 B295FC35FFF for ; Fri, 21 Mar 2025 11:33:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5698280002; Fri, 21 Mar 2025 07:33:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B044A280001; Fri, 21 Mar 2025 07:33:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A598280002; Fri, 21 Mar 2025 07:33:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7C58F280001 for ; Fri, 21 Mar 2025 07:33:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 90C66AB45B for ; Fri, 21 Mar 2025 11:33:56 +0000 (UTC) X-FDA: 83245348872.21.5826EC1 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf17.hostedemail.com (Postfix) with ESMTP id F37714000C for ; Fri, 21 Mar 2025 11:33:53 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=VrAS6S8q; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=HWPeSFxj; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=VrAS6S8q; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=HWPeSFxj; spf=pass (imf17.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742556834; 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=fW1zj69AyHS8QvZf6eMqCoAwxWFzA9rEhGNVFV6bgfA=; b=OC1MoYSB4CKz3hhmGe4z5q101lU8Y6rO2Z8tGRSGdKsVgBDCHbyAVGwl5Cv9P3iKfaxXLN w2zDdSTnG7EmU9DeBWBSz0kaW8QxZerYHQWZDw0u1X7XbtJzi7xa0B/8+BYq0KyKJF+Ko/ 68xoDQYm1yZwWohZekGp13oni8rsLRc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=VrAS6S8q; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=HWPeSFxj; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=VrAS6S8q; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=HWPeSFxj; spf=pass (imf17.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742556834; a=rsa-sha256; cv=none; b=vYKlFB+zK3HIi7RTKhGLMgqx5V6wdfXublh7xuxACwxsFBsIq+NAmfcyleeJPutUR3rW9w ZIVyUo/dFYEgvuddog0PU1HBWkSoSKRfPSyf/8ba4xlXajUfFkfoaqSL/2aZJV9jruoCAS rTzRNHIWvyr0Vn25BTx6uNV4bTk4ApM= 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-out2.suse.de (Postfix) with ESMTPS id 5C0681F78F; Fri, 21 Mar 2025 11:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1742556832; 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=fW1zj69AyHS8QvZf6eMqCoAwxWFzA9rEhGNVFV6bgfA=; b=VrAS6S8qNve/p7u33K19g4zLOe28lWvZyxPP0I22SbANR91cCQD8I6oPTBFVuzL8Oq7pcP YFUerpNphh7Hi59AeJvsA2wCS9j6teNDs9yoLiwUxSpe1fAFFcOlBL/is5vpGQihSGiAsO 6BUjGxsQw3J2Z6wL87zGMK8NoZqnfSQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1742556832; 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=fW1zj69AyHS8QvZf6eMqCoAwxWFzA9rEhGNVFV6bgfA=; b=HWPeSFxjRCuICyqT4ksF2wHEURrbbAVQ5gnRwudHVxgWLlA6gAJwvVH5KqChRRNmwoDwlc yVf6AvBd5B1feVBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1742556832; 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=fW1zj69AyHS8QvZf6eMqCoAwxWFzA9rEhGNVFV6bgfA=; b=VrAS6S8qNve/p7u33K19g4zLOe28lWvZyxPP0I22SbANR91cCQD8I6oPTBFVuzL8Oq7pcP YFUerpNphh7Hi59AeJvsA2wCS9j6teNDs9yoLiwUxSpe1fAFFcOlBL/is5vpGQihSGiAsO 6BUjGxsQw3J2Z6wL87zGMK8NoZqnfSQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1742556832; 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=fW1zj69AyHS8QvZf6eMqCoAwxWFzA9rEhGNVFV6bgfA=; b=HWPeSFxjRCuICyqT4ksF2wHEURrbbAVQ5gnRwudHVxgWLlA6gAJwvVH5KqChRRNmwoDwlc yVf6AvBd5B1feVBg== 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 45F02139AA; Fri, 21 Mar 2025 11:33:52 +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 l7jAEKBO3Wf3QwAAD6G6ig (envelope-from ); Fri, 21 Mar 2025 11:33:52 +0000 Message-ID: Date: Fri, 21 Mar 2025 12:33:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/2] Fix parameter passed to page_mapcount_is_type() Content-Language: en-US To: Gavin Shan , David Hildenbrand , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, willy@infradead.org, osalvador@suse.de, gehao@kylinos.cn, shan.gavin@gmail.com References: <20250321053148.1434076-1-gshan@redhat.com> <0d096764-302f-4b80-a867-22f5302b8045@redhat.com> <5ec97dd6-6561-4687-ac94-41c63ffc82cf@redhat.com> From: Vlastimil Babka In-Reply-To: <5ec97dd6-6561-4687-ac94-41c63ffc82cf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: F37714000C X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature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Qe6F47GLHLpCUZDlqd9xKTy5xVbdojrslbu3371X26uyHAf+ug+8Lpt5P7iguHSVY1FfhQQtWsiCZqngvlT0bmLemKKUv2aaKyn8oQOPCcqmEhVoxnWwCXxxFlNRJby+5SnDFRqg0/uUbHTiid9/zNIcmOJFcxid1LImvD6POz8jcDxSUUkzrHDYrouyI6dPJTQU5JcLcLke1LZPg+amrx40ym7mDujty6uhXREr7dKT4BIsTKzwkje+Ie0Nsc7fz6sTb9QBggyLVMrG3PMBoH2JXeYkW/JBDy5dNk0Qkxh9F0KXH1O21qfZxQYDsEAS+w6iTC9Cw79OxNpNsNb4OAKBpx97zE2TCgknBCHldnunICOYenO2sqlwTc60pM9GY8qBx2Xpw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000081, 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 12:25, Gavin Shan wrote: > On 3/21/25 8:11 PM, David Hildenbrand wrote: >> On 21.03.25 10:23, Vlastimil Babka wrote: >>> On 3/21/25 06:31, Gavin Shan wrote: >>>> Found by code inspection. There are two places where the parameter >>>> passed to page_mapcount_is_type() is (page->__mapcount), which is >>>> correct since it should be one more than the value, as explained in >>>> the comments to page_mapcount_is_type(): (a) page_has_type() in >>>> page-flags.h (b) __dump_folio() in mm/debug.c >>> >>> IIUC you are right. Luckily thanks to the the PGTY_mapcount_underflow limit, >>> this off-by-one error doesn't currently cause visible issues i.e. >>> misclassifications legitimate mapcount as page type and vice versa, right? >>> We'd have to have a mapcount underflown severely right to the limit to make >>> that off-by-one error cross it? >> >> Agreed. Likely not stable material because it isn't actually fixing anything (because of the safety gaps). >> > > Yes, it shouldn't cause any visible impacts so far due to the gap. Thanks for confirming, please state that in the commit log/cover letter too. > I just found the issue by code inspection. Lets drop the fix tags > in v2. Fixes: tag is fine and correct, just Cc: stable is unnecessary. Thanks. >>> >>> I wonder if a more future-proof solution would be to redefine >>> page_mapcount_is_type() instead to not subtract. But I'll leave that to willy. >> >> With upcoming changes around that, likely best to leave that alone. I expect page_mapcount_is_type() to completely vanish. >> > > +1 to remove page_mapcount_is_type(). After Willy confirms, I can post > an extra series to do it if needed. > > Thanks, > Gavin >