Received: by 2002:a05:7208:2202:b0:86:316c:7444 with SMTP id s2csp2370810rbb; Tue, 4 Jun 2024 03:29:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLX8WDy6R+YaAVvGd1+SylQ60xV47NMlPVvuAlltJrnK5YMe9LTbVrIYU3v+NQv84PrAOiqCwupbk6Z3kBSFqCkKDj9Rt+I8lWWzeL4g== X-Google-Smtp-Source: AGHT+IFGB5F1KpF9xAEWaYRcLMTZip3sLgVnPhWPN/RcpEK6XdU9jaemWqgDJRZQGR088z7LUuUb X-Received: by 2002:a05:6214:c4f:b0:6ab:9c77:c32c with SMTP id 6a1803df08f44-6aff728c2f9mr35896976d6.10.1717496992513; Tue, 04 Jun 2024 03:29:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717496992; cv=pass; d=google.com; s=arc-20160816; b=JLFOuyPdqEXkvhIbDQ3XFdS/X9vDL2RqVnNtb4+zDJzy/P8xRr9AfrisT4R5jhmoiG LmCYu0jML6A26c+f3s6Ooc1K405+F0BMgYM0OD8cI0K6o07O+sDsZJ0hCokGVG83EmDf QW43zL9Z7LxYDr1tyAYOZYf3fx+YWC1yMJ9IzGoQidIUVYifLyxU7xYV9ksy3ASv9bcw Ez3k+4nQqYJ7RVHoZsPkLTFCGp8EAKJoGfyInDo0vjeCKXGoHd6F2siXlKi95LR1sJhI mamrG1QtfRlOFZ78H+U1q9z3ZUTg0SWhFM2oEVVSJUiAJhrL3pugpJIBVgc47WK5v4uO rTEg== 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=6DG7DXE2JJh9dM3bhGo7RQTMbF5V2xeF0wZaeXe7lOs=; fh=zdlpYOFPQVSnY1yuuAgszbPxKcvjKTkVdGgcZVAG5H8=; b=QiHw8+/eMA0nIpoeAQDopHvMuQIZHKhcZzsIK3yuLGffjkQRGdQCdqB6vgZmpvl0yL GJS+eal+g23b+u3+suazkHfEZCUwA+R5jJ6ZNTc2Y1ISoAgq6PAAf3gGZJjubAKQEk+u hVtnb6ye9lK0SkXL3Hocq3vROO08SF+bp35QqbkKdBtees7FmLDZ6B/wxlgSEZBMurtn IP3gQYb2dE4Do3O5aGmGD1X9u2KrREMz9xywVizvyUI0R7bM6olcluisDDo9YKlq436+ sY+XMS3tCvYD3fU6S/pvrgfjKgmeHovKHFqIFruhWKHANwXoJs7ZPBt4vPN6UhApd8Vo jRGQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pankajraghav.com header.s=MBO0001 header.b=rp6HJoAr; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-200423-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b401d9dsi108563806d6.294.2024.06.04.03.29.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 03:29:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200423-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=@pankajraghav.com header.s=MBO0001 header.b=rp6HJoAr; arc=pass (i=1 spf=pass spfdomain=pankajraghav.com dkim=pass dkdomain=pankajraghav.com dmarc=pass fromdomain=pankajraghav.com); spf=pass (google.com: domain of linux-kernel+bounces-200423-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pankajraghav.com 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 1DC031C221A0 for ; Tue, 4 Jun 2024 10:29:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF1D9144D0E; Tue, 4 Jun 2024 10:29:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b="rp6HJoAr" Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (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 A8B2329401; Tue, 4 Jun 2024 10:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717496981; cv=none; b=PWbM3M/8aTmw4tC+YVoU1GrOLmNJr+r2hx++QH7rpRtubRkNeQ7p5bMnn3fJzyeiVzmiNQq8pygO9CZ8n0eIlB2l2tRRD/E8kxuMuJeNgTlQTR3wUqm3XyrcbIClgOszNB2ue9yxzcCpjl5wi7v19oC5iM0lSpAARsge9MYrHg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717496981; c=relaxed/simple; bh=BQ+qiq72QPdaBXb30EQGfPMHadzeqg43TjzADDa4iJA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=F6Mr6sxo3byVovmgpJxFDHr3vzE7ZQuRRP7QKitZsmcZZsIwRwsKi/LUex98YEGkNNb0U8H/Vq/eI0eHFg1yxdMhh0FqBgXF5G/naZydm+0F+pWe87h92oBdwS9al7YZz/O4NZXLk/x+rR7KjAyjFVCx0fR7ocqNMZMPIv5QcX8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com; spf=pass smtp.mailfrom=pankajraghav.com; dkim=pass (2048-bit key) header.d=pankajraghav.com header.i=@pankajraghav.com header.b=rp6HJoAr; arc=none smtp.client-ip=80.241.56.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pankajraghav.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pankajraghav.com Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::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 mout-p-201.mailbox.org (Postfix) with ESMTPS id 4Vtmzt1dBjz9sS2; Tue, 4 Jun 2024 12:29:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1717496970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6DG7DXE2JJh9dM3bhGo7RQTMbF5V2xeF0wZaeXe7lOs=; b=rp6HJoAr4fgn8D/Lj3iM+i2F/Bkkah1tOkbOY3bFKl3+D6oskWV+IVl4f4fY7q49kt4oJY PecYhtX+D45PzWEvv0NaHqK+hDsMs1YUuzzdS02RRSMarCRks2Zh+RxHJAEv7lPhiecDGT O4RHqW3zPVzx+TjgEPU6GT1fveYC5d+NpIRI23HIpf4KndEokN/ti0YAjO10KfJfT8JVl3 D397p4GHT6fAhAWQyZ54Vx3o0yDI1oDRZfzRWLzy+qZcoNBb0DnOjyMqPZVvVZFX5axh7N DjrOhaIEALi7giAnw0mqMUlY0PCNOnLlOJkHlkH3aHfHlm+S8+0KypkCo1uuSg== Date: Tue, 4 Jun 2024 10:29:24 +0000 From: "Pankaj Raghav (Samsung)" To: Matthew Wilcox 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: <20240604102924.u6n35x4rfzdvis3l@quentin> 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: X-Rspamd-Queue-Id: 4Vtmzt1dBjz9sS2 On Mon, Jun 03, 2024 at 01:36:46PM +0100, Matthew Wilcox wrote: > 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? > > > + } You are right. There are some repetition and checks that are not needed. I will clean this function for the next revision. Thanks. -- Pankaj