Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp38098rdb; Tue, 16 Jan 2024 14:13:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHG7DPJ3VMiBXodDQI0oYQOk8+l8BRCBlzDMn3jhR002lZxH7bvxttLerC+n/vJRhTHyL1f X-Received: by 2002:a05:6808:112:b0:3bd:5a02:e0dd with SMTP id b18-20020a056808011200b003bd5a02e0ddmr7687130oie.118.1705443185272; Tue, 16 Jan 2024 14:13:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705443185; cv=pass; d=google.com; s=arc-20160816; b=dor77FCjUVtp8Hk9f+siQXwxKkoFg7mPemeS81BFwPVUHrx3GBwfAV0XTZFnQ99vhE xKY3UoHJFb/ErTivi46s/ZFOFZUuT0INP/WCjBZGzHzzp/U2N49c+ltpr6UXx5T8cCbp N6debh8X3sr4AKU/xHNJMaJv5TeVWDZZOF5tuJ/eG3N3mk0+KcQQpoVEIZKTySzhR9Qp jlYfGf2SQMx+S4l16afY12QkCDMFbl3SFf3ikHYTbsOeMQA36mcOrm5004Zmq0C9QAEp G5EYQizIwHcNfcJzvAaDE7+jn3EZySQQCl2Hoda/tW4JhHXjlnM/qvtkQvj2vTuVujo7 9aNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gqUubKJHRY6K9pinfjqkAiFXi2Gpkb784msqSrmTGmg=; fh=rTAAvuZQJSQY509Ig3rJdiGNxV8bG6nCi5Wdi6YIpVE=; b=sZz/IH2loS7szWZKxh8y7IVbRY2UOz02tYc+VR8G0yDsJpyVLbRd1EjtM4H1y5rTOo ysfH76HspTwo1+VOtT4px87tlDXJFybjV/SbhZ9ZutVGJ26FvlDos9BFQzLL8aegDeaF YXiHaTsTDgohI/WabmNAWdv8YCGA7840nkvxgS52N2dJ1KGs+zf95v5//WaIeVIWjBQL pOxjsSOr6PaFM94nid/iNzIVMKgL7jjaezAA5jxWkZtTeLyqC5HKZWrr9HbNo2NlCD8S hKSdHPB9KOjM+gNl0Ap9OWyfix2uJPIbRX0K3IvSd1g1oDDOzUZ1G//L6vRDVAm5qS82 mR9Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HjOFhrbq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-28249-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r9-20020a05622a034900b0042a0915c7absi1327952qtw.9.2024.01.16.14.13.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 14:13:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28249-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HjOFhrbq; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-28249-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0AD4D1C27720 for ; Tue, 16 Jan 2024 22:13:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1980B224FB; Tue, 16 Jan 2024 20:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HjOFhrbq" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3D649224E7; Tue, 16 Jan 2024 20:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705437135; cv=none; b=KPVSFvCpKj5NSYSVZifhtyXsY6xnUZdExf20OEojWrVOaHEcs9ybeD/f4Bi4s7dv0B1B2yMl83f3cD9VhHLPJMgdGhvge+7I0TQcYHNmY6mOa4AoWBbpzwJhbeqBfg3a9Inu9eGgNUBb9H3cIdNm51yEXHy27JXHHAMFS+rSzi8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705437135; c=relaxed/simple; bh=0gNuhgg77yxXDonAd8TaqH0VHZHjbXRDBmWe7QPHx4w=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-Id: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=cYI4eXvxFpbtacd8KZqgHjOm+vz7eghjdeOEmVfxmwJxgDikGPPTtePbVBDBzBL/tN/jvQ72xzEigx4RSKTOOgkf0BuTJ9IB1BAO+Rk7KD2sLZ0uEpSDyDeBkSPx4TkyXFeW0JPXEc4gOaf86TPoweZ/6qMA30EJJJlbqeNNomY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HjOFhrbq; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BAC0C433F1; Tue, 16 Jan 2024 20:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705437134; bh=0gNuhgg77yxXDonAd8TaqH0VHZHjbXRDBmWe7QPHx4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HjOFhrbqv0DoCJkjrlCoAB7fz/4ibnyb9//Y+6gWP43abhAV+FYMPB8l06SBOAAN1 qGLS91p1JfEmQUcOt1R/UqBBYbpSJwHaUDNrHorlGjD2XA+NsreiQs9qxRGn0jnh5a 26aztPnxE1i1NiyRYTzyRT91+w6vUYQnGV0FvOe074J0WQFOfG8NiOmrLDL5R1oMQl 9D4pMrcJHJuDxZu24ukl9dVooFe2v9+YI/2RNwne+7Nsz0Mnr+OjqGTlncFgFQzGvQ VLHTAix+8mc6YuxYx2v6KLYu06fU0+lFxDTm4YvHGKB2yKoQ29eWf2Ykcwl5823vI+ ZLcM3fYLAhRzQ== From: SeongJae Park To: Honggyu Kim Cc: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel_team@skhynix.com, akpm@linux-foundation.org, apopple@nvidia.com, baolin.wang@linux.alibaba.com, dave.jiang@intel.com, linmiaohe@huawei.com, lizhijian@cn.fujitsu.com, mathieu.desnoyers@efficios.com, mhiramat@kernel.org, rostedt@goodmis.org, surenb@google.com, yangx.jy@fujitsu.com, ying.huang@intel.com, ziy@nvidia.com Subject: Re: [RFC PATCH 1/4] mm/vmscan: refactor reclaim_pages with reclaim_or_migrate_folios Date: Tue, 16 Jan 2024 12:32:10 -0800 Message-Id: <20240116203210.52843-1-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115045253.1775-2-honggyu.kim@sk.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Mon, 15 Jan 2024 13:52:49 +0900 Honggyu Kim wrote: > Since we will introduce reclaim_pages like functions such as > demote_pages and promote_pages, the most of the code can be shared. > > This is a preparation patch that introduces reclaim_or_migrate_folios() > to cover all the logics, but it provides a handler for the different > actions. > > No functional changes applied. > > Signed-off-by: Honggyu Kim > --- > mm/vmscan.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index bba207f41b14..7ca2396ccc3b 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2107,15 +2107,16 @@ static unsigned int reclaim_folio_list(struct list_head *folio_list, > return nr_reclaimed; > } > > -unsigned long reclaim_pages(struct list_head *folio_list) > +static unsigned long reclaim_or_migrate_folios(struct list_head *folio_list, > + unsigned int (*handler)(struct list_head *, struct pglist_data *)) I'm not very sure if extending this function for general migration is the right approach, since we have dedicated functions for the migration. I'd like to hear others' opinions. > { > int nid; > - unsigned int nr_reclaimed = 0; > + unsigned int nr_folios = 0; > LIST_HEAD(node_folio_list); > unsigned int noreclaim_flag; > > if (list_empty(folio_list)) > - return nr_reclaimed; > + return nr_folios; > > noreclaim_flag = memalloc_noreclaim_save(); > > @@ -2129,15 +2130,20 @@ unsigned long reclaim_pages(struct list_head *folio_list) > continue; > } > > - nr_reclaimed += reclaim_folio_list(&node_folio_list, NODE_DATA(nid)); > + nr_folios += handler(&node_folio_list, NODE_DATA(nid)); > nid = folio_nid(lru_to_folio(folio_list)); > } while (!list_empty(folio_list)); > > - nr_reclaimed += reclaim_folio_list(&node_folio_list, NODE_DATA(nid)); > + nr_folios += handler(&node_folio_list, NODE_DATA(nid)); > > memalloc_noreclaim_restore(noreclaim_flag); > > - return nr_reclaimed; > + return nr_folios; > +} > + > +unsigned long reclaim_pages(struct list_head *folio_list) > +{ > + return reclaim_or_migrate_folios(folio_list, reclaim_folio_list); > } > > static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan, > -- > 2.34.1