Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1022174lqj; Mon, 3 Jun 2024 08:02:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPaxf6bSt/Sm72I8c9UC82Y/l9EgubAqutgwtldIAVI13HrXSYm0RKudM6puWF2pZQZPR2F1wETeiopIrk2xY3UJp+GxS728tchdnvRQ== X-Google-Smtp-Source: AGHT+IHdusk+krf6cllUbfMp+RGtqa169vC+ohIgGE+6vxbbjmTZ4fS9Wgk1bXnOhdUNOhddoG6f X-Received: by 2002:a19:ac0c:0:b0:51c:bd90:e60b with SMTP id 2adb3069b0e04-52b8957ebfamr6516626e87.25.1717426971281; Mon, 03 Jun 2024 08:02:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717426971; cv=pass; d=google.com; s=arc-20160816; b=FDoOWm5vKObdrp70pZEacxpBskSQXGYRuhgJ4HDXQINqMTVkZBq3uglfW2aBB7A9Kn BG3S9DZhGaFmu5px+MU+ofC1sLK6F7MFXBXQAXAo1YUPeWbb+0Wsj8uXQb2nB1i2o7I5 56cuhXIfrCZwX+IrQivrNNUHzsJUTN2MA3S93WRVVNZMQ+3+nook5NTcKQwwe1vXudXL MvvLDRrVIc5/srubB4mQj9BaCZY0MqNPwf+i+Mzjur5LpGj3e3LcHRWaXEXeh4re1I/8 pdMuKzy5EDLZcfIszh4KK7R3/xOZccdPFjOW6Z9I1DMq/q3TPnCFyCifO+O/XnE7JPUR BVLQ== 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=7C0eF6nlIGCKMOH3zNzr9pWa+xfNDLGWYp9HnkvxvOw=; fh=qSU4Sk5xQBMjV1B7aQyMHA9Xwajt+VtcmRb1vyT+YiU=; b=RuMbV+WJt59zuWzwaGnrbZYt46bSCQtKvz2IfgcXiUNR2zdKhx8bkCjocFAj15xhb3 o8cEmTIGuX65XCxcy7x3k7YLnB9aDvabhO94izs5FEVL2KeK8ZXJrgYFhd3k77tZQNwf KrOmwPI9oo53MdL5xSCxTYG1y+r4DvR6IJ1v8LgGer7a21w2olnc1G9TYIxFXn9VWDZw bSa8grdMf9sFuyzJxS/v5Wg8iZQ1vipBIVCXq5xzcnk6m2F86kkKZelYxt6oyuA/slD5 qA6w9SSytH0wUqKOHyBWH4ufjdHAtxNqs8ASnhayHxfMCSB7k5+kqoYxNsrhJ65aYT/d 6kXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Qu3MYxmZ; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-199117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199117-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 a640c23a62f3a-a67eaf65151si423450466b.868.2024.06.03.08.02.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 08:02:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199117-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=Qu3MYxmZ; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-199117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199117-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 A9AED1F240CE for ; Mon, 3 Jun 2024 12:37:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D13412C487; Mon, 3 Jun 2024 12:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Qu3MYxmZ" 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 EC81164F; Mon, 3 Jun 2024 12:36:52 +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=1717418214; cv=none; b=kr6B3KGUPdSM2/vsRRQTG5pd2lEzJrwb8HNLuaPW8mRufSqouHuF5eYcn49brtVUI6CPSikT9O39qpHj1XrI5Q48tnFFVDbjZbZgD+hZbsT1V5Fq46zn2hfy7jVKo2IXS44/yYclYD/wbSKjfPw22xftks3kJQeIYA8saPwrbFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717418214; c=relaxed/simple; bh=t1T26TRB9XYsNoZ575DQn4UY8pOFxLN+NFaGfC3uQX0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sYluMXEgxlli2GJA2WFSSrK6I9RbED1O1s+aAuCOxXDZx57uPwvZWtf7iTXbdgec0bVdbGMEjNhkCaTALGfd2dJWuEEOeZdw8EgnNosA/xUTtrhY6A4dxnSSy5SMKLNQkbNuFj7A7HFKY9ldhLtS8fRMVlMrl+9JFEMwvs7DiY4= 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=Qu3MYxmZ; 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=7C0eF6nlIGCKMOH3zNzr9pWa+xfNDLGWYp9HnkvxvOw=; b=Qu3MYxmZEw2c4/kq5YqDisMcfE T3EEy9+eBLkbf3m3LBWAdhU/l0k9B8cacnrBC9uulnLzicX4+IdesmhBMPK5VYN5Id/TOvRi3t0vr Pkg6jZUIg4NHgEvTPofHJ/bQEmq/NSgudg9keRezfDlbQ+LgFw4Vl+LQqUr8ncm0sMDORewAZTQGe QE0FwLaZlaQKXwpvd381tpYZMcQV/tsfDjR68AWBLseeYE5MDXhgjX3PkP3xbPH7Qx6m4MJpefgnu 6+CssTsUmfcZbb5VJhLhLR0lOPUiEHKRgMlQpqlyUVMdwnMBduN6rGwFgJuN9c4lJWVe+f/LY8eg4 VETO2aUA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sE6ve-0000000E5zG-18Wz; Mon, 03 Jun 2024 12:36:46 +0000 Date: Mon, 3 Jun 2024 13:36:46 +0100 From: Matthew Wilcox To: "Pankaj Raghav (Samsung)" Cc: david@fromorbit.com, chandan.babu@oracle.com, akpm@linux-foundation.org, brauner@kernel.org, djwong@kernel.org, linux-kernel@vger.kernel.org, hare@suse.de, john.g.garry@oracle.com, gost.dev@samsung.com, yang@os.amperecomputing.com, p.raghav@samsung.com, cl@os.amperecomputing.com, linux-xfs@vger.kernel.org, hch@lst.de, mcgrof@kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v6 05/11] mm: split a folio in minimum folio order chunks Message-ID: References: <20240529134509.120826-1-kernel@pankajraghav.com> <20240529134509.120826-6-kernel@pankajraghav.com> 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: <20240529134509.120826-6-kernel@pankajraghav.com> On Wed, May 29, 2024 at 03:45:03PM +0200, Pankaj Raghav (Samsung) wrote: > @@ -3572,14 +3600,19 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start, > > for (index = off_start; index < off_end; index += nr_pages) { > struct folio *folio = filemap_get_folio(mapping, index); > + unsigned int min_order, target_order = new_order; > > nr_pages = 1; > if (IS_ERR(folio)) > continue; > > - if (!folio_test_large(folio)) > + if (!folio->mapping || !folio_test_large(folio)) > goto next; This check is useless. folio->mapping is set to NULL on truncate, but you haven't done anything to prevent truncate yet. That happens later when you lock the folio. > + min_order = mapping_min_folio_order(mapping); You should hoist this out of the loop. > + if (new_order < min_order) > + target_order = min_order; > + > total++; > nr_pages = folio_nr_pages(folio); > > @@ -3589,7 +3622,18 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start, > if (!folio_trylock(folio)) > goto next; > > - if (!split_folio_to_order(folio, new_order)) > + if (!folio_test_anon(folio)) { Please explain how a folio _in a file_ can be anon? > + unsigned int min_order; > + > + if (!folio->mapping) > + goto next; > + > + min_order = mapping_min_folio_order(folio->mapping); > + if (new_order < target_order) > + target_order = min_order; Why is this being repeated? > + } > + > + if (!split_folio_to_order(folio, target_order)) > split++; > > folio_unlock(folio); > -- > 2.34.1 >