Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp370182lqp; Thu, 21 Mar 2024 04:05:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkBQliXJCFEW1BMlTn9H13/lMfq65A/yk3giKxLkFwlM1yqFdn/aynEjCuSO502kp77VvFvFB8k/XLjrTSKwYNguZkxmTIFJngxw4+Nw== X-Google-Smtp-Source: AGHT+IE1Vzup+P7AlMKv6lThKhsserTpMJrifBicvQM+4xehbSg0/trow9enc4M6nvN0kdhkR9Zo X-Received: by 2002:a05:6102:d92:b0:476:977a:8f28 with SMTP id d18-20020a0561020d9200b00476977a8f28mr1904181vst.17.1711019157295; Thu, 21 Mar 2024 04:05:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711019157; cv=pass; d=google.com; s=arc-20160816; b=Oh+wlIEjn/0B7wDR0Bs+pCxAhV9CVuGYEeKyxkaAqbeQwL+gHMg8fR6GrcR+nWkknG IMq5qiAyWPTd138kS5Ssrx3Yy5uKJZXqHxROenA5HRMPxmcNvBwyBV/dLE4A9/GbnM0F bLVlKVaOhJl5h0eFhET1PwvaKIH3wRSdF+FIxG336Gk57FObgSdEw7kIjuTxXoKFuksk uQWMYIJFXEmVdsTpPHiUxiOq2aMcooCE18RyTRuGroIEpLv6gOkpcaNWjbUArEaGijXw sVUvjkep9w8xw4EJr2Xtom+rZWYkTWYUj7MrbR6ftJlIOLFFA/xxQJSMiklo0sSm5YnE EAXw== 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; bh=dyELGGqmhTemgq4PrUb9aK3KgDPWeltECWKvGU8DyUo=; fh=YfPLb1HuXa89UdINaP4JQ1p91GoiJS/GYs6Ejtj3XVs=; b=U9JyitYoemLvKUkYRCcDMQTCxmOcN+IvyS9ARIshuLu5xWHitgr+be200YUcDOTGgG MuAwXLUHPe+5q724hyA/oPgnw5ou9J4z/JZsbLoeGQvG5N4Nlr5tI4gePXauZ3X64gJs ctz1YvLadd+GO3KQqNGhymEs0p/ERNIgDRbTiCmkHjV19sWUnNKcxJ7OjxYOwJcpIeL3 zOsuIfkVAIGgIV8CWk43hvX9ROvkxB6lonSmUeS6tcxct9CvxtloBup/5BtrS1LxcNsT MJc/GgI7q8xQMpuxEBFJs9OnIUFK23/G2jbbQOD5W/dxFP8TJK8MLGxxKwm88U5fXB+v goEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-109919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v14-20020a67f1ce000000b00476016e7a18si1807310vsm.607.2024.03.21.04.05.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 04:05:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-109919-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0863C1C225D6 for ; Thu, 21 Mar 2024 11:05:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17CE057884; Thu, 21 Mar 2024 11:05:46 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 0D16B57311 for ; Thu, 21 Mar 2024 11:05:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711019145; cv=none; b=AWZj8gkNGXyT63Ua7f1JLCKzB+1oG838qEJQUMdN8SpO/VoK1H1nE0G4EBl0PsIZUD+6gHKj7eqtTLhFx5yRPcE3fc0FpLD9/toh+Jrtr/mh/xPawCd6F6Gh/NxaFPQpQigwBAikFW/EY/2TODE685wvg8l/jDI/tjeGVrchHl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711019145; c=relaxed/simple; bh=slbxlN2nSei3VCKDGLMiugztkO4zWq96JKaboOhSAAU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=f0/CeZEFBLLoyVHuMhJkyM7J+oTEWVgMLIctGyx28MRu4Gujpg1rSBP/3DU/yJiUDXdFZFQge5FOENqFzTYIkHjH7HClDBAkYqAzp8uQ5jYwutaWDp/lGbKB+KoYPDbcQTnT4oicDcKprAsEB2e5aKCz9H71tCH8gdCys7jHGiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 6973B37268; Thu, 21 Mar 2024 11:05:37 +0000 (UTC) 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 D1123136AD; Thu, 21 Mar 2024 11:05: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 8LM4MIAU/GUXKwAAD6G6ig (envelope-from ); Thu, 21 Mar 2024 11:05:36 +0000 Date: Thu, 21 Mar 2024 12:07:02 +0100 From: Oscar Salvador To: Vlastimil Babka Cc: Matthew Wilcox , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Marco Elver , Andrey Konovalov , Alexander Potapenko , Tetsuo Handa Subject: Re: [PATCH v2 2/2] mm,page_owner: Fix accounting of pages when migrating Message-ID: References: <20240319183212.17156-1-osalvador@suse.de> <20240319183212.17156-3-osalvador@suse.de> 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: X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 6973B37268 X-Spam-Flag: NO On Thu, Mar 21, 2024 at 11:50:36AM +0100, Vlastimil Babka wrote: > Yeah I think we could keep that logic. I am all for keeping it. > 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. Since new_page will have the old handle pointing to the old stack after the call, we could uncharge the old_page to the migrate_stack, which new_page->_handle holds before it gets changed. So we basically swap it. It could work, but I kinda have a bittersweet feeling here. I am trying to work towards to reduce the number of lookups in the hlist, but for the approach described above I would need to lookup the stack for new_page->handle in order to substract the page. OTHO, I understand that adding migrate_handle kinda wasted memory. 16MB for 16GB of memory. > 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. I did not check deeply but do not we split the folio upon migration in case it is large? Which means we should reach split_page_owner() before the copy takes place. Do I get it right? -- Oscar Salvador SUSE Labs