From: Yunsheng Lin <linyunsheng@huawei.com>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Subbaraya Sundeep" <sbhatta@marvell.com>,
"Chuck Lever" <chuck.lever@oracle.com>,
"Sagi Grimberg" <sagi@grimberg.me>,
"Jeroen de Borst" <jeroendb@google.com>,
"Praveen Kaligineedi" <pkaligineedi@google.com>,
"Shailend Chand" <shailend@google.com>,
"Eric Dumazet" <edumazet@google.com>,
"Tony Nguyen" <anthony.l.nguyen@intel.com>,
"Przemek Kitszel" <przemyslaw.kitszel@intel.com>,
"Sunil Goutham" <sgoutham@marvell.com>,
"Geetha sowjanya" <gakula@marvell.com>,
hariprasad <hkelam@marvell.com>, "Felix Fietkau" <nbd@nbd.name>,
"Sean Wang" <sean.wang@mediatek.com>,
"Mark Lee" <Mark-MC.Lee@mediatek.com>,
"Lorenzo Bianconi" <lorenzo@kernel.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Keith Busch" <kbusch@kernel.org>, "Jens Axboe" <axboe@kernel.dk>,
"Christoph Hellwig" <hch@lst.de>,
"Chaitanya Kulkarni" <kch@nvidia.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"David Howells" <dhowells@redhat.com>,
"Marc Dionne" <marc.dionne@auristor.com>,
"Jeff Layton" <jlayton@kernel.org>, "Neil Brown" <neilb@suse.de>,
"Olga Kornievskaia" <kolga@netapp.com>,
"Dai Ngo" <Dai.Ngo@oracle.com>, "Tom Talpey" <tom@talpey.com>,
"Trond Myklebust" <trondmy@kernel.org>,
"Anna Schumaker" <anna@kernel.org>,
"Shuah Khan" <shuah@kernel.org>,
intel-wired-lan@lists.osuosl.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-nvme@lists.infradead.org, kvm@vger.kernel.org,
virtualization@lists.linux.dev, linux-mm@kvack.org,
bpf@vger.kernel.org, linux-afs@lists.infradead.org,
linux-nfs@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v13 04/14] mm: page_frag: add '_va' suffix to page_frag API
Date: Tue, 20 Aug 2024 21:07:29 +0800 [thread overview]
Message-ID: <98ceade3-8d60-45bf-a419-ff3982a96101@huawei.com> (raw)
In-Reply-To: <CAKgT0UcDDFeMqD_eRe1-2Og0GEEFyNP90E9SDxDjskdgtMe0Uw@mail.gmail.com>
On 2024/8/19 23:54, Alexander Duyck wrote:
...
>>>>
>>>> "There are three types of API as proposed in this patchset instead of
>>>> two types of API:
>>>> 1. page_frag_alloc_va() returns [va].
>>>> 2. page_frag_alloc_pg() returns [page, offset].
>>>> 3. page_frag_alloc() returns [va] & [page, offset].
>>>>
>>>> You seemed to miss that we need a third naming for the type 3 API.
>>>> Do you see type 3 API as a valid API? if yes, what naming are you
>>>> suggesting for it? if no, why it is not a valid API?"
>>>
>>> I didn't. I just don't see the point in pushing out the existing API
>>> to support that. In reality 2 and 3 are redundant. You probably only
>>> need 3. Like I mentioned earlier you can essentially just pass a
>>
>> If the caller just expect [page, offset], do you expect the caller also
>> type 3 API, which return both [va] and [page, offset]?
>>
>> I am not sure if I understand why you think 2 and 3 are redundant here?
>> If you think 2 and 3 are redundant here, aren't 1 and 3 also redundant
>> as the similar agrument?
>
> The big difference is the need to return page and offset. Basically to
> support returning page and offset you need to pass at least one value
> as a pointer so you can store the return there.
>
> The reason why 3 is just a redundant form of 2 is that you will
> normally just be converting from a va to a page and offset so the va
> should already be easily accessible.
I am assuming that by 'easily accessible', you meant the 'va' can be
calculated as below, right?
va = encoded_page_address(encoded_va) +
(page_frag_cache_page_size(encoded_va) - remaining);
I guess it is easily accessible, but it is not without some overhead
to calculate the 'va' here.
>
>>> page_frag via pointer to the function. With that you could also look
>>> at just returning a virtual address as well if you insist on having
>>> something that returns all of the above. No point in having 2 and 3 be
>>> seperate functions.
>>
>> Let's be more specific about what are your suggestion here: which way
>> is the prefer way to return the virtual address. It seems there are two
>> options:
>>
>> 1. Return the virtual address by function returning as below:
>> void *page_frag_alloc_bio(struct page_frag_cache *nc, struct bio_vec *bio);
>>
>> 2. Return the virtual address by double pointer as below:
>> int page_frag_alloc_bio(struct page_frag_cache *nc, struct bio_vec *bio,
>> void **va);
>
> I was thinking more of option 1. Basically this is a superset of
> page_frag_alloc_va that is also returning the page and offset via a
> page frag. However instead of bio_vec I would be good with "struct
> page_frag *" being the value passed to the function to play the role
> of container. Basically the big difference between 1 and 2/3 if I am
> not mistaken is the fact that for 1 you pass the size, whereas with
> 2/3 you are peeling off the page frag from the larger page frag cache
Let's be clear here: The callers just expecting [page, offset] also need
to call type 3 API, which return both [va] and [page, offset]? and it
is ok to ignore the overhead of calculating the 'va' for those kinds
of callers just because we don't want to do the renaming for a existing
API and can't come up with good naming for that?
> after the fact via a commit type action.
Just be clear here, there is no commit type action for some subtype of
type 2/3 API.
For example, for type 2 API in this patchset, it has below subtypes:
subtype 1: it does not need a commit type action, it just return
[page, offset] instead of page_frag_alloc_va() returning [va],
and it does not return the allocated fragsz back to the caller
as page_frag_alloc_va() does not too:
struct page *page_frag_alloc_pg(struct page_frag_cache *nc,
unsigned int *offset, unsigned int fragsz,
gfp_t gfp)
subtype 2: it does need a commit type action, and @fragsz is returned to
the caller and caller used that to commit how much fragsz to
commit.
struct page *page_frag_alloc_pg_prepare(struct page_frag_cache *nc,
unsigned int *offset,
unsigned int *fragsz, gfp_t gfp)
Do you see subtype 1 as valid API? If no, why?
If yes, do you also expect the caller to use "struct page_frag *" as the
container? If yes, what is the caller expected to do with the size field in
"struct page_frag *" from API perspective? Just ignore it?
next prev parent reply other threads:[~2024-08-20 13:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240808123714.462740-1-linyunsheng@huawei.com>
[not found] ` <20240808123714.462740-2-linyunsheng@huawei.com>
2024-08-09 11:08 ` [PATCH net-next v13 01/14] mm: page_frag: add a test module for page_frag Muhammad Usama Anjum
2024-08-09 12:29 ` Yunsheng Lin
[not found] ` <20240808123714.462740-3-linyunsheng@huawei.com>
2024-08-14 15:33 ` [PATCH net-next v13 02/14] mm: move the page fragment allocator from page_alloc into its own file Alexander H Duyck
2024-08-14 20:22 ` Andrew Morton
[not found] ` <20240808123714.462740-5-linyunsheng@huawei.com>
2024-08-14 15:49 ` [PATCH net-next v13 04/14] mm: page_frag: add '_va' suffix to page_frag API Alexander H Duyck
2024-08-15 2:59 ` Yunsheng Lin
2024-08-15 15:00 ` Alexander Duyck
2024-08-16 11:55 ` Yunsheng Lin
2024-08-19 15:54 ` Alexander Duyck
2024-08-20 13:07 ` Yunsheng Lin [this message]
2024-08-20 16:02 ` Alexander Duyck
2024-08-21 12:30 ` Yunsheng Lin
[not found] ` <20240808123714.462740-8-linyunsheng@huawei.com>
2024-08-14 16:13 ` [PATCH net-next v13 07/14] mm: page_frag: reuse existing space for 'size' and 'pfmemalloc' Alexander H Duyck
2024-08-15 3:10 ` Yunsheng Lin
2024-08-15 15:03 ` Alexander Duyck
2024-08-16 11:55 ` Yunsheng Lin
2024-08-19 16:00 ` Alexander Duyck
[not found] ` <20240808123714.462740-9-linyunsheng@huawei.com>
2024-08-14 17:54 ` [PATCH net-next v13 08/14] mm: page_frag: some minor refactoring before adding new API Alexander H Duyck
2024-08-15 3:04 ` Yunsheng Lin
2024-08-15 15:09 ` Alexander Duyck
2024-08-16 11:58 ` Yunsheng Lin
[not found] ` <20240808123714.462740-12-linyunsheng@huawei.com>
2024-08-14 21:00 ` [PATCH net-next v13 11/14] mm: page_frag: introduce prepare/probe/commit API Alexander H Duyck
2024-08-15 3:05 ` Yunsheng Lin
2024-08-15 15:25 ` Alexander Duyck
2024-08-16 12:01 ` Yunsheng Lin
2024-08-19 15:52 ` Alexander Duyck
2024-08-20 13:08 ` Yunsheng Lin
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=98ceade3-8d60-45bf-a419-ff3982a96101@huawei.com \
--to=linyunsheng@huawei.com \
--cc=Dai.Ngo@oracle.com \
--cc=Mark-MC.Lee@mediatek.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.duyck@gmail.com \
--cc=andrii@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=anna@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=bpf@vger.kernel.org \
--cc=chuck.lever@oracle.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=gakula@marvell.com \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=hch@lst.de \
--cc=hkelam@marvell.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jasowang@redhat.com \
--cc=jeroendb@google.com \
--cc=jlayton@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=kolga@netapp.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=lorenzo@kernel.org \
--cc=marc.dionne@auristor.com \
--cc=martin.lau@linux.dev \
--cc=matthias.bgg@gmail.com \
--cc=mst@redhat.com \
--cc=nbd@nbd.name \
--cc=neilb@suse.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pkaligineedi@google.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=sagi@grimberg.me \
--cc=sbhatta@marvell.com \
--cc=sdf@fomichev.me \
--cc=sean.wang@mediatek.com \
--cc=sgoutham@marvell.com \
--cc=shailend@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--cc=virtualization@lists.linux.dev \
--cc=yonghong.song@linux.dev \
/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