Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1494878lqt; Wed, 20 Mar 2024 06:01:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVqJagL4kIfXJ5G0Kiy5dmzPm2X4xV2k2hWW5J1JX1F/GhDpwI+l7VELCNeBvodB+W/8etsi345mgBk0ZNux8ftbkgELJH2qouU4/7FIQ== X-Google-Smtp-Source: AGHT+IG9flg52mSdM0Wqta7gl7CEqUfS5W6e1VI5xJqnKWnpErR3+3FbVpo9f1rPcQacZO/XmyLO X-Received: by 2002:a17:906:5a88:b0:a46:fba6:eef7 with SMTP id l8-20020a1709065a8800b00a46fba6eef7mr793095ejq.23.1710939685404; Wed, 20 Mar 2024 06:01:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710939685; cv=pass; d=google.com; s=arc-20160816; b=GLv8OG5xLUZqmDhfsZWnaAe0oDl9mpaF4Qv9MP0O7JclKWbp6Kk3WIcc5wSZXrMvWz Aa3yaXvL3+lus5R286m+b1bNZeJTabgykPrgtdu7NZni80PA6vDuboL6SRn3ZKxJBpXw /eFZ198UMtvBpHY/yQz13TqMiYMV3I3aOEIkE7cOvi9rhBnACiSVU2jItN0Es8oOCGP1 +qkdPLJx/zLTKV5EUII9OmmAiUn92XX+OkbdnKyIKpaaGl/e7yh8F4qrKHtZib+EOCWA BEsFiVThFIOwDLSUZ7pD/4DAJ4AMb0bf0NGDrRXWotkqpBAR+SNh7xkkGq9m1UhXx5qo TrmA== 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=Pcs/qG/ocyE/tlTca8TkKVXl8mnst2CUx2O+igwbRzI=; fh=ieeEHCSmkFZzD0II1P2iPLHoQdL5rt4/kKBbteAFI8k=; b=KlI54wqsVFClfHtIl+5Rl9mgnvZocvZkpYHWG/hL86iKKZCiXKAwPQU45i10gpr4KZ ifBgvW8cxDfijLdy8RGa7l7WzIcgTAZCmG25Pji7mI1UAJjnfE15VO4C0wF8tWhitWvD eKEGgzdlzF3xPOBaiivicWb9qBmHPg0a067zko1+1iRsUE0QO6HIIstSS6UE+M/j9Kj6 PLn1knYkLfaudQJzQlYOQkLywEmxxShgaMYUaH6rgSUgCgQWRoh1pdI3Yjwp8Mp1QpiJ 2aY6OuBRlbu4ESmpnM5LDdvqacTrTFPMlVOdf0vuly2VXtn/WZai5xjVB/RF/4FRYKNS 4oNQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=R9snuk0E; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-108925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108925-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lu2-20020a170906fac200b00a46cb8e0f34si2572291ejb.772.2024.03.20.06.01.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 06:01:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=R9snuk0E; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-108925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108925-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 25BD41F24ABE for ; Wed, 20 Mar 2024 13:01:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FDC44085F; Wed, 20 Mar 2024 13:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="R9snuk0E" 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 2D8A34084A for ; Wed, 20 Mar 2024 13:01:16 +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=1710939678; cv=none; b=TxHEY601zP/jhaSlQOVY4b1CeWtS+65nxkVexp4qT/neNjA7BsgEWIE1Dt67sToNQgDaSzP/9C2EyWAcdSSiRBFW87uXOwGhMq1SJGqiZNttl82ZKZWiqrEVslolr+cz+YDKckQR6m1KG6oe3XewDk6mRnw4dGcweNG03WzU5U0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710939678; c=relaxed/simple; bh=BO+73+xIJDj6fO5JS9nxVFoht09VhXIE75p+8aYFASU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hu7zzTG4tFoD5MweoXw2TPkV2H9EaFngWct58XOwb5c2kI0YFELRthUs1SJLe1IqmSPEnqUYQusoMn7AJjXsduAvSsg4uNxus3iMKtc5iY9+l9Axk1dImLOqDkMvIft9p36zIAPr7BR+LBYcaZ1BpiiQztuekk6hBIWS+MfNK2Q= 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=R9snuk0E; 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=Pcs/qG/ocyE/tlTca8TkKVXl8mnst2CUx2O+igwbRzI=; b=R9snuk0E2vaBgnxz7miYmX5FOe 8ho70rGWZUDLIOHgErUJpawK6NtkPaaw4znVkvXxj6cDVa3pF/DwsCri3aJYW5Ee5n8EYVCHCefr+ RmPRR+IyMC201dc5hTT2Dt3G9tqR9JYRYKhBAMlpSRF6t6PBhA8HKNq/gDwpah8BJr1rsmT6494gz z0jUceKAtpTjyc20uph3JoYD5fywmMPqzUvM9SyznO1D0YxeSyokls6eq4dyttX89qcBnJu9VmFWj 1yMRM0z4xcjt8xtThjTKxcPczW0Bj7aZ1mCb9GzwSEzEWyiqMZlYCXNu2ywwjuB7dT1e2GXdhkW/Q qa38H1OA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmvYw-00000004L7b-24U0; Wed, 20 Mar 2024 13:00:58 +0000 Date: Wed, 20 Mar 2024 13:00:58 +0000 From: Matthew Wilcox To: alexs@kernel.org Cc: Izik Eidus , Andrea Arcangeli , Hugh Dickins , Chris Wright , kasong@tencent.com, Andrew Morton , "open list:MEMORY MANAGEMENT" , open list Subject: Re: [PATCH 03/11] mm/ksm: use a folio in remove_stable_node Message-ID: References: <20240320074049.4130552-1-alexs@kernel.org> <20240320074049.4130552-4-alexs@kernel.org> 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: <20240320074049.4130552-4-alexs@kernel.org> On Wed, Mar 20, 2024 at 03:40:39PM +0800, alexs@kernel.org wrote: > @@ -1124,22 +1124,22 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) > * merge_across_nodes/max_page_sharing be switched. > */ > err = -EBUSY; > - if (!page_mapped(page)) { > + if (!folio_mapped(folio)) { > /* > * The stable node did not yet appear stale to get_ksm_page(), > - * since that allows for an unmapped ksm page to be recognized > + * since that allows for an unmapped ksm folio to be recognized > * right up until it is freed; but the node is safe to remove. > - * This page might be in an LRU cache waiting to be freed, > + * This folio might be in an LRU cache waiting to be freed, > * or it might be PageSwapCache (perhaps under writeback), s/PageSwapCache/in the swapcache/ > * or it might have been removed from swapcache a moment ago. > */ > - set_page_stable_node(page, NULL); > + set_page_stable_node(&folio->page, NULL); Before this patch, introduce a folio_set_stable_node() (and convert the one caller which already has a folio). I'd do it the other way around from ksm_get_folio(); that is: static inline void folio_set_stable_node(struct folio *folio, struct ksm_stable_node *stable_node) { set_page_stable_node(&folio->page, stable_node); } and then we can merge the two later when there are no more calls to set_page_stable_node().