From: Hannes Reinecke <hare@suse.de>
To: Daniel Gomez <da.gomez@samsung.com>,
"minchan@kernel.org" <minchan@kernel.org>,
"senozhatsky@chromium.org" <senozhatsky@chromium.org>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"djwong@kernel.org" <djwong@kernel.org>,
"willy@infradead.org" <willy@infradead.org>,
"hughd@google.com" <hughd@google.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"mcgrof@kernel.org" <mcgrof@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: "gost.dev@samsung.com" <gost.dev@samsung.com>,
Pankaj Raghav <p.raghav@samsung.com>
Subject: Re: [RFC PATCH 09/11] shmem: add order arg to shmem_alloc_folio()
Date: Tue, 31 Oct 2023 08:04:06 +0100 [thread overview]
Message-ID: <735f3692-2932-4986-abec-c217da182f71@suse.de> (raw)
In-Reply-To: <20231028211518.3424020-10-da.gomez@samsung.com>
On 10/28/23 23:15, Daniel Gomez wrote:
> Add folio order argument to the shmem_alloc_folio() and merge it with
> the shmem_alloc_folio_huge(). Return will make use of the new
> page_rmappable_folio() where order-0 and high order folios are
> both supported.
>
> Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
> ---
> mm/shmem.c | 33 ++++++++++-----------------------
> 1 file changed, 10 insertions(+), 23 deletions(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index d8dc2ceaba18..fc7605da4316 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1614,40 +1614,27 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp)
> return result;
> }
>
> -static struct folio *shmem_alloc_hugefolio(gfp_t gfp,
> - struct shmem_inode_info *info, pgoff_t index)
> +static struct folio *shmem_alloc_folio(gfp_t gfp, struct shmem_inode_info *info,
> + pgoff_t index, unsigned int order)
> {
> struct mempolicy *mpol;
> pgoff_t ilx;
> struct page *page;
>
> - mpol = shmem_get_pgoff_policy(info, index, HPAGE_PMD_ORDER, &ilx);
> - page = alloc_pages_mpol(gfp, HPAGE_PMD_ORDER, mpol, ilx, numa_node_id());
> + mpol = shmem_get_pgoff_policy(info, index, order, &ilx);
> + page = alloc_pages_mpol(gfp, order, mpol, ilx, numa_node_id());
> mpol_cond_put(mpol);
>
> return page_rmappable_folio(page);
> }
>
> -static struct folio *shmem_alloc_folio(gfp_t gfp,
> - struct shmem_inode_info *info, pgoff_t index)
> -{
> - struct mempolicy *mpol;
> - pgoff_t ilx;
> - struct page *page;
> -
> - mpol = shmem_get_pgoff_policy(info, index, 0, &ilx);
> - page = alloc_pages_mpol(gfp, 0, mpol, ilx, numa_node_id());
> - mpol_cond_put(mpol);
> -
> - return (struct folio *)page;
> -}
> -
> static struct folio *shmem_alloc_and_add_folio(gfp_t gfp,
> struct inode *inode, pgoff_t index,
> struct mm_struct *fault_mm, size_t len)
> {
> struct address_space *mapping = inode->i_mapping;
> struct shmem_inode_info *info = SHMEM_I(inode);
> + unsigned int order = 0;
> struct folio *folio;
> long pages;
> int error;
> @@ -1668,12 +1655,12 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp,
> index + HPAGE_PMD_NR - 1, XA_PRESENT))
> return ERR_PTR(-E2BIG);
>
> - folio = shmem_alloc_hugefolio(gfp, info, index);
> + folio = shmem_alloc_folio(gfp, info, index, HPAGE_PMD_ORDER);
> if (!folio)
> count_vm_event(THP_FILE_FALLBACK);
> } else {
> - pages = 1;
> - folio = shmem_alloc_folio(gfp, info, index);
> + pages = 1UL << order;
> + folio = shmem_alloc_folio(gfp, info, index, order);
> }
> if (!folio)
> return ERR_PTR(-ENOMEM);
> @@ -1774,7 +1761,7 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp,
> */
> gfp &= ~GFP_CONSTRAINT_MASK;
> VM_BUG_ON_FOLIO(folio_test_large(old), old);
> - new = shmem_alloc_folio(gfp, info, index);
> + new = shmem_alloc_folio(gfp, info, index, 0);
Shouldn't you use folio_order(old) here?
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman
next prev parent reply other threads:[~2023-10-31 7:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230919135546eucas1p1181b8914fb5eceda5f08068802941358@eucas1p1.samsung.com>
2023-09-19 13:55 ` [PATCH v2 0/6] shmem: high order folios support in write path Daniel Gomez
2023-09-19 13:55 ` [PATCH v2 1/6] shmem: drop BLOCKS_PER_PAGE macro Daniel Gomez
2023-09-19 13:55 ` [PATCH v2 2/6] shmem: return freed pages in shmem_free_swap Daniel Gomez
2023-09-19 14:56 ` Matthew Wilcox
2023-09-19 13:55 ` [PATCH v2 3/6] shmem: account for large order folios Daniel Gomez
2023-09-19 13:55 ` [PATCH v2 4/6] shmem: add order parameter support to shmem_alloc_folio Daniel Gomez
2023-09-19 13:55 ` [PATCH v2 5/6] shmem: add file length in shmem_get_folio path Daniel Gomez
2023-09-19 13:55 ` [PATCH v2 6/6] shmem: add large folios support to the write path Daniel Gomez
2023-09-19 15:01 ` Matthew Wilcox
2023-09-19 16:28 ` Daniel Gomez
2023-10-28 21:15 ` [RFC PATCH 00/11] shmem: high order folios support in " Daniel Gomez
2023-10-28 21:15 ` [RFC PATCH 01/11] XArray: add cmpxchg order test Daniel Gomez
2023-10-29 20:11 ` Matthew Wilcox
2023-11-03 23:12 ` Daniel Gomez
2023-10-28 21:15 ` [RFC PATCH 02/11] test_xarray: add tests for advanced multi-index use Daniel Gomez
2023-10-28 21:15 ` [RFC PATCH 03/11] shmem: drop BLOCKS_PER_PAGE macro Daniel Gomez
2023-10-28 21:15 ` [RFC PATCH 04/11] shmem: return number of pages beeing freed in shmem_free_swap Daniel Gomez
2023-10-28 21:15 ` [RFC PATCH 05/11] shmem: account for large order folios Daniel Gomez
2023-10-29 20:40 ` Matthew Wilcox
2023-10-28 21:15 ` [RFC PATCH 06/11] shmem: trace shmem_add_to_page_cache folio order Daniel Gomez
2023-10-29 23:14 ` Matthew Wilcox
2023-10-28 21:15 ` [RFC PATCH 07/11] shmem: remove huge arg from shmem_alloc_and_add_folio() Daniel Gomez
2023-10-29 23:17 ` Matthew Wilcox
2023-10-28 21:15 ` [RFC PATCH 08/11] shmem: add file length arg in shmem_get_folio() path Daniel Gomez
2023-10-28 21:15 ` [RFC PATCH 09/11] shmem: add order arg to shmem_alloc_folio() Daniel Gomez
2023-10-31 7:04 ` Hannes Reinecke [this message]
2023-10-28 21:15 ` [RFC PATCH 10/11] shmem: add large folio support to the write path Daniel Gomez
2023-10-29 23:32 ` Matthew Wilcox
2023-10-28 21:15 ` [RFC PATCH 11/11] shmem: add per-block uptodate tracking Daniel Gomez
2023-10-29 20:43 ` [RFC PATCH 00/11] shmem: high order folios support in write path Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=735f3692-2932-4986-abec-c217da182f71@suse.de \
--to=hare@suse.de \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=da.gomez@samsung.com \
--cc=djwong@kernel.org \
--cc=gost.dev@samsung.com \
--cc=hughd@google.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=minchan@kernel.org \
--cc=p.raghav@samsung.com \
--cc=senozhatsky@chromium.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox