Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp362675lqp; Thu, 21 Mar 2024 03:50:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGoHn/iCSAPWDDBUHm+Qa/24Qnx+I599Je/IS2FYs30A4hAORpB4TYQG3bjA1K/iq8RGZjY80O/JjoEZbnh97NjsAIP9Q7HE1lBqkqKg== X-Google-Smtp-Source: AGHT+IEbhyF+tXdll5r2vU8d7PZwBV36lp2jzFaina/1MOnTlJEBuQLWfI6RHAW2lzQdD8s3XvAX X-Received: by 2002:a05:6a20:a103:b0:1a3:5e4c:b3b6 with SMTP id q3-20020a056a20a10300b001a35e4cb3b6mr9972936pzk.48.1711018248891; Thu, 21 Mar 2024 03:50:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711018248; cv=pass; d=google.com; s=arc-20160816; b=BbUjNCaf5ksjHUJNiNHxs3cV13kXeM5A2c0yHX1cf4SyQHAqbdg9izZpzMA1kmrebS u8Y9H57so6RYBr3vcOPlxAMynLxlxiMQNkRWWpdEsNRsHYmcHczYOSwXGX/K0aFY8ZLI 7yygmScPSYa9xEYAjbgUb/t7geSMSZddOi3zebMGF8xFu4fleFhMdlvZtnQWUw6wjRYy v3V7qjpQu2yO/k2YPIGQ9sSlM8jZzZlMzVcx4lxj8n0pCbwiFOISNjg/CfzoyuHLjgy9 qUFNQXa2MFXO8eDIngUpdiF72yFoL9cWOhL75DAwFnNC3SRZ++umyA/T7nlWz5VfO0vI aEKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=3MkA3INDRNrQmyii/A1Er4UKsQqNsow2c9O8EOAoimo=; fh=9j+KIpZvdTHZOA0I3GzjspiBwkWZuUYMksxN8ufEzrU=; b=H4g/8e2BvEB7Z0LuHXvmlTnGTvl2gWd8uSSBEZqQILFXzdab+rvVsS6lvagnVOT8+d WCC38xwrCu9WAjD0oWqvMFtmu9vEW2F2FZPHuHERm79SVsBoDEfxOko+MdQbdhHzV/ck F/b8Ee0sXrXDteuq3CQcvOenlqqpIDMtwq+SARS2TBN1nxCzmwNlkc+83i6r3FnH/OKZ j6x20rX6BTJ0hRzgflQu+HGhrDvIbrtCINKTX3Jcd6ZquHiK7SQVHmKt1tkqZ8fepgb6 yTbe0PYRoX3cJnR8hdsvT2Ua1Lguaj+VszDDcWRhOnAMJn8eizJLnBNRJCSXtzFBpmnd OWOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TGV647uj; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=bf3yVEuQ; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-109907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109907-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 n15-20020a170902d2cf00b001def26cd3f1si12527430plc.461.2024.03.21.03.50.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 03:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109907-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=@suse.cz header.s=susede2_rsa header.b=TGV647uj; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=bf3yVEuQ; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-109907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109907-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 8BF9A282D1A for ; Thu, 21 Mar 2024 10:50:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1C705730C; Thu, 21 Mar 2024 10:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="TGV647uj"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="O0um/ZCs"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="bf3yVEuQ"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="UafGAvGq" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2236B5644E for ; Thu, 21 Mar 2024 10:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711018240; cv=none; b=VBUx6z/jRcS7iY2NRUL7Fb+/BMST8ripmkvBmeZspPqXfy7SVI/lT8wcaPFhrf3YE2RO3AaeJst7ZL/6pTuuWc7QthtDM5jsWq9T8fTJfTkPW+ATH1nDglIFF5Usrdx95rXV3RuVE65z6Vqk6nKTjd0SEFcQzA/OaHrLXBXeKwc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711018240; c=relaxed/simple; bh=HX68hSzTAcjMDkDZGRIL39hdwSHNbaZPZnmVZn4Yons=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=C/1xneUzQIZzRdHdQnc6xkeJY2tpwpaMuQjVxatQcD6xtNIjsCC0q103MVKMNqXFoZVYsHWI4cqP5I7m9Lko/nw2DsNT7Czhp1qySR/U5LgFWmYtFuGNzgMDF/JjXu0DJnRhfh9jBZsZmfWITSp71+Cqcg+8cjEtUrn8df+hrTc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=TGV647uj; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=O0um/ZCs; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=bf3yVEuQ; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=UafGAvGq; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 E5EFB5CC90; Thu, 21 Mar 2024 10:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711018237; 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=3MkA3INDRNrQmyii/A1Er4UKsQqNsow2c9O8EOAoimo=; b=TGV647ujMQMD9P/44azK1++hnYVprPTitT1iBwUxc3WKMcwcwAH+qmJZMY0PXCALBlbuRV xQk91wyrYLPY/JAWPV3hRUuOqg60Gp8/0nyy3Yq3FywIKc1OixnP2sIhwYPZw1uL0+mVYR sAgbJhwBRDOPJAgUkDgXqkSX9pGqIQQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711018237; 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=3MkA3INDRNrQmyii/A1Er4UKsQqNsow2c9O8EOAoimo=; b=O0um/ZCsYEDTkSq6O/1z+N6jBNMwWroTr0EEDcPFJhvwkuFbvVeLLrsDQEG87XUWG3bA0A OkCyyjsCGI6Q8yCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711018236; 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=3MkA3INDRNrQmyii/A1Er4UKsQqNsow2c9O8EOAoimo=; b=bf3yVEuQ0R7YJNEJO87pQGedAOLqemHiYI6CdtPgLob77SIfhK+/CZjpilvGPlZUq3n5sr rEZe7zEHzqYrgOW+TG++qOTOrXXMRAEmStMUJsRhOLIIznlFhagO71gakZ5lo9jNqXrtyN 3e2/UII5UXz4pxRqVbiHKJFQxy9ilH4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711018236; 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=3MkA3INDRNrQmyii/A1Er4UKsQqNsow2c9O8EOAoimo=; b=UafGAvGqBrejNTrrT3Lsf9XntQh5zFs41qz06HNSy77C9TRt6So1WyXOQuow0DUEhTRiBP 3NnxdpRghbLSCSAA== 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 CD366136AD; Thu, 21 Mar 2024 10:50:36 +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 T2PAMfwQ/GUVJgAAD6G6ig (envelope-from ); Thu, 21 Mar 2024 10:50:36 +0000 Message-ID: Date: Thu, 21 Mar 2024 11:50:36 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] mm,page_owner: Fix accounting of pages when migrating Content-Language: en-US To: Oscar Salvador , Matthew Wilcox Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Marco Elver , Andrey Konovalov , Alexander Potapenko , Tetsuo Handa References: <20240319183212.17156-1-osalvador@suse.de> <20240319183212.17156-3-osalvador@suse.de> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -1.29 X-Spamd-Result: default: False [-1.29 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[10]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; BAYES_HAM(-0.00)[30.81%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[linux-foundation.org,vger.kernel.org,kvack.org,suse.com,google.com,gmail.com,i-love.sakura.ne.jp]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO On 3/20/24 06:00, Oscar Salvador wrote: > On Tue, Mar 19, 2024 at 06:48:31PM +0000, Matthew Wilcox wrote: >> Is this the right way to fix this problem? I would have thought we'd >> be better off accounting this as migration freeing the old page and >> allocating the new page. If I understand correctly, this is the code >> which says "This page was last allocated by X and freed by Y", and I >> would think that being last freed (or allocated) by the migration code >> would be a very nice hint about where a problem might stem from. > > I hear you, and I had the same thought when I stumbled upon this. > I did not know that the handle was being changed, otherwise it would > have saved me quite a lot of debugging time. > > Checking the history of this, I can see this decision was made in > 2016 in: > > commit d435edca928805074dae005ab9a42d9fa60fc702 > Author: Vlastimil Babka > Date: Tue Mar 15 14:56:15 2016 -0700 > > mm, page_owner: copy page owner info during migration > Yeah I think we could keep that logic. But we could also simply subtract the refcount of the old handle (the "allocated for migration") in __folio_copy_owner() no? Then we wouldn't need the extra migrate_handle. Also we might have more issues here. Most page owner code takes care to set everything for all pages within a folio, but __folio_copy_owner() and __set_page_owner_migrate_reason() don't.