Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1073897lqt; Tue, 19 Mar 2024 11:48:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZ0YgjQniNujeOJjQewkazHSqzlKiLOf4PXyhtE8TQYPyC7fO3wxaaGRckS5AvRQSUO0h5K5OYKNi7XzYdCKx4VR2sPGnpAgge/O5r5Q== X-Google-Smtp-Source: AGHT+IHCAFcNlRLBe98kPwf25SWAFIbtvSwvZ2FsGwVGo06JRu/8soeOUzuADYOEAAe64IgCmGOQ X-Received: by 2002:a05:6870:5388:b0:221:f5f5:50c9 with SMTP id h8-20020a056870538800b00221f5f550c9mr3867754oan.2.1710874124260; Tue, 19 Mar 2024 11:48:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710874124; cv=pass; d=google.com; s=arc-20160816; b=UZtzKqesYxjiU0bi3zZWD9OYzZT2gPUVywbf1Yqu/CInC2rVj3tw5sKMuN2ScnhNvs 1t79u8pgOFlH6BGgKXrgNiHkv4sagTv3kJZflqBXZ5cJMww1qkH/V8pVhSHrH/SHilp2 c48C4qQAf/gW8YceRZa0mWYuIbo4j74fTqwNxTSpEaXloFNm+6gkFgVYRMyZE1XIoOBO DoysMIsoyMc1mn9qjKhSn9YhbxW2n59rIlT12QgYbrLUSffRNAOZAty5VYoIuTEU9yXJ Hh63cajWEvl7y7a3axxPSsXK7XmOwFNx7ujTR3AVNmcpVPLgtCyYfpPcAqPtO+LxNrW5 LQzQ== 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:dkim-signature; bh=OExp50z/CnQde4C4dQqyxK/JMlnOceYMC0oR3+8P3LY=; fh=TygVD68YyN6IklyQj1z1l1BfaBUoRtraNPxsR+bFOYI=; b=sg/XZ+dK+U6NFrEnDiLQM6+foLzCS+qP6P13JV5QyR158h7GBXLfkE/95kw1H0P+1Y ybVuVs3k+8jyC5tZogWSFEIjXxGVNphlxPqTlWhbpQO/5c0X5UDoiVCEU2kcdmeQViZW 8ovCuXwR1qYpNnflffhhxRpEc4gwtAUztD0dXW20tmkQ1V8LIZjORnlbx9sdtNukjKwj U2vgXdAXuBqRFs9GyRnb4gQT3V5yZXRKSh1yKOi9zw/MiNlyHcsToUbYEDCkBGB5kQet FmCKYjYTare02wKehpuIdR6YILISxVoc0soAdnMcYUorzdKhJwcqY0G0ForjeCACLTIg rm8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Z9J0FnTr; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-108037-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108037-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 67-20020a630246000000b005cdf8b03384si10508646pgc.805.2024.03.19.11.48.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 11:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108037-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=@infradead.org header.s=casper.20170209 header.b=Z9J0FnTr; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-108037-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108037-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 A24A928563A for ; Tue, 19 Mar 2024 18:48:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA1163987D; Tue, 19 Mar 2024 18:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Z9J0FnTr" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86691EBB for ; Tue, 19 Mar 2024 18:48:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710874116; cv=none; b=P+LCA5MN64OFa/oj0MF3jP5XE34/CWiirpXObZMi5THTRdRfPo1B6IlM/5a2hiSB969IPWEBT+IxpwdkW4NTyDqsWUCNHToiXzdL+4LKnDEtosOMZ6y6gYaTqJRdrFmcDeF3p6++zFZrTXP4YNpITA6L8eOoPtDBuP/wTpu8hjA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710874116; c=relaxed/simple; bh=WGPvd5GwZ6PqsjHNqitGV0Y88GPZKt3oT2QOZMOdvXw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BH6HlLVBBjBnff3O/9C+rEvPJSOy8u6izLudK3SuQ7m9JP3G1Qye5SDz+L5gJa70+kVVNDgqNMXsKlk5bXpqTJb5qHsCLujYBk6MT9JeY8vR/njn/yRUMI8bFV9TiKwG0D4LdO7B/LyH59a4fA5BBzec9R63qaDuZF5kdj8cWmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Z9J0FnTr; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OExp50z/CnQde4C4dQqyxK/JMlnOceYMC0oR3+8P3LY=; b=Z9J0FnTr60WoOmwI3hRQIpYOaK I9uX4ILY4VyWJSko3IrpQUp5GKVKUmkpScDpudtH2cDvnKEXbIiM6VyChCyiLuXe4tjRPU2cj8r7P MVSI4RNLZwV8WTt3FTQYgRHWV/YBGt75DhJaz0v5yoHK8MGGCbWUlY31+vbR9DYtU8321dfbL7P5f Jw5gUSB1QyaU7DvM22vUAqLnapFb0AsbzlMHox5GnSY+JBEwZbss3INBezQ6nqLDLrFql1+12W7EC 34M8KrEjqEAtPHtiFcWX33Ir7EUZCrNcVSO4+qT8++v5sAA9pn+vmR+I3ycVZugGD30V3UwpC6KBe 7lWJYLoA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmeVk-00000002X1Z-05zV; Tue, 19 Mar 2024 18:48:32 +0000 Date: Tue, 19 Mar 2024 18:48:31 +0000 From: Matthew Wilcox To: Oscar Salvador Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , 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: <20240319183212.17156-3-osalvador@suse.de> On Tue, Mar 19, 2024 at 07:32:12PM +0100, Oscar Salvador wrote: > Upon migration, new allocated pages are being given the handle of the old > pages. This is problematic because it means that for the stack which > allocated the old page, we will be substracting the old page + the new one > when that page is freed, creating an accounting imbalance. > > Fix this by adding a new migrate_handle in the page_owner struct, and > record the handle that allocated the new page in __folio_copy_owner(). > Upon freeing, we check whether we have a migrate_handle, and if we do, > we use migrate_handle for dec_stack_record_count(), which will > subtract those pages from its right handle. 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.