From: "Arnd Bergmann" <arnd@arndb.de>
To: "Nhat Pham" <nphamcs@gmail.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Matthew Wilcox" <willy@infradead.org>,
bfoster@redhat.com, kernel-team@meta.com,
linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH v9 2/3] cachestat: implement cachestat syscall
Date: Mon, 13 Feb 2023 08:00:06 +0100 [thread overview]
Message-ID: <3f70f54e-206f-438e-9ef4-2cd514d3a690@app.fastmail.com> (raw)
In-Reply-To: <CAKEwX=MneVSm49FYxNAP+-uQijOZnNfWjuzF7FPub_rcDFY__A@mail.gmail.com>
On Sun, Feb 12, 2023, at 07:58, Nhat Pham wrote:
> On Sun, Feb 5, 2023 at 4:56 PM Arnd Bergmann <arnd@arndb.de> wrote:
>> On Fri, Feb 3, 2023, at 20:04, Nhat Pham wrote:
>>
>> > +SYSCALL_DEFINE5(cachestat, unsigned int, fd, loff_t, off, size_t, len,
>> > + struct cachestat __user *, cstat, unsigned int, flags)
>> > +{
>> > + return ksys_cachestat(fd, off, len, cstat, flags);
>> > +}
>> > +
>> > +#ifdef CONFIG_COMPAT
>> > +COMPAT_SYSCALL_DEFINE6(cachestat, unsigned int, fd,
>> > compat_arg_u64_dual(off),
>> > + size_t, len, struct cachestat __user *, cstat, unsigned int, flags)
>> > +{
>> > + return ksys_cachestat(fd, compat_arg_u64_glue(off), len, cstat,
>> > flags);
>> > +}
>>
>> This still looks wrong to me, as this compat definition does not match
>> the native variant on architectures that require 64-bit arguments to
>> be passed in aligned register pairs, such as arm, mips or ppc, but
>> not x86, s390 or riscv.
>
> Oh I see - thanks for pointing that out! And the last bit means this
> is a non-issue for x86, s390 or riscv right?
Right. It still requires the separate compat entry point that we
generally try to avoid for new syscalls, but it's probably still
better than passing the offset through a pointer.
> And iirc from the last thread, this is fixable via a simple reordering
> of the args in order to properly align the 64-bit arguments, for e.g:
>
> SYSCALL_DEFINE5(cachestat, loff_t, off, unsigned int, fd, size_t, len,
> struct cachestat __user *, cstat, unsigned int, flags)
>
> ...
>
> COMPAT_SYSCALL_DEFINE6(cachestat, compat_arg_u64_dual(off),
> unsigned int, fd, size_t, len, struct cachestat __user *, cstat,
> unsigned int, flags)
>
>
> It looks a bit odd to me that fd is not the first argument, but perhaps this
> is an acceptable sacrifice to avoid unused arg and keep the flags...
>
> Let me know what you think about this!
Right, this should work. You can also move the offset to the third
or fifth argument in order to keep the fd one first.
I would actually like to change all the syscalls that have loff_t
arguments to have explicit '64-bit' and '32-bit' versions rather
than 'native' and 'compat', to make it more obvious what is going on
even on the architectures that have no 64-bit variant.
That is something to do later though, you should definitely keep
doing this the same way we do for all other syscalls.
Arnd
next prev parent reply other threads:[~2023-02-13 7:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 19:04 [PATCH v9 0/3] cachestat: a new syscall for page cache state of files Nhat Pham
2023-02-03 19:04 ` [PATCH v9 1/3] workingset: refactor LRU refault to expose refault recency check Nhat Pham
2023-02-03 19:04 ` [PATCH v9 2/3] cachestat: implement cachestat syscall Nhat Pham
2023-02-03 22:10 ` kernel test robot
2023-02-03 22:10 ` kernel test robot
2023-02-03 22:10 ` kernel test robot
2023-02-05 9:55 ` Arnd Bergmann
2023-02-12 7:17 ` Nhat Pham
[not found] ` <CAKEwX=MneVSm49FYxNAP+-uQijOZnNfWjuzF7FPub_rcDFY__A@mail.gmail.com>
2023-02-13 7:00 ` Arnd Bergmann [this message]
2023-02-03 19:04 ` [PATCH v9 3/3] selftests: Add selftests for cachestat Nhat Pham
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=3f70f54e-206f-438e-9ef4-2cd514d3a690@app.fastmail.com \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=bfoster@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).