From: Julien Grall <julien@xen.org>
To: Costin Lupu <costin.lupu@cs.pub.ro>, xen-devel@lists.xenproject.org
Cc: Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH v3 3/5] tools/libs/foreignmemory: Fix PAGE_SIZE redefinition error
Date: Mon, 17 May 2021 19:12:27 +0100 [thread overview]
Message-ID: <690806fb-e6e2-f61f-d7d6-a17efa6329d9@xen.org> (raw)
In-Reply-To: <2040286fc39b7e1d46376a8e75ac59d8d3be5aff.1620633386.git.costin.lupu@cs.pub.ro>
Hi Costin,
On 10/05/2021 09:35, Costin Lupu wrote:
> @@ -168,7 +168,7 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
> size_t i;
> int rc;
>
> - addr = mmap(addr, num << PAGE_SHIFT, prot, flags | MAP_SHARED,
> + addr = mmap(addr, num << XC_PAGE_SHIFT, prot, flags | MAP_SHARED,
> fd, 0);
> if ( addr == MAP_FAILED )
> return NULL;
> @@ -198,9 +198,10 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
> */
> privcmd_mmapbatch_t ioctlx;
> xen_pfn_t *pfn;
> - unsigned int pfn_arr_size = ROUNDUP((num * sizeof(*pfn)), PAGE_SHIFT);
> + unsigned int pfn_arr_size = ROUNDUP((num * sizeof(*pfn)), XC_PAGE_SHIFT);
> + int os_page_size = getpagesize();
Hmmm... Sorry I only realized now that the manpage suggests that
getpagesize() is legacy:
SVr4, 4.4BSD, SUSv2. In SUSv2 the getpagesize() call is labeled
LEGACY, and in POSIX.1-2001 it has been dropped; HP-UX does not have
this call.
And then:
Portable applications should employ sysconf(_SC_PAGESIZE) instead of
getpagesize():
#include <unistd.h>
long sz = sysconf(_SC_PAGESIZE);
As this is only used by Linux, it is not clear to me whether this is
important. Ian, what do you think?
>
> - if ( pfn_arr_size <= PAGE_SIZE )
> + if ( pfn_arr_size <= os_page_size )
Your commit message suggests we are only s/PAGE_SHIFT/XC_PAGE_SHIFT/ but
this is using getpagesize() instead. I agree it should be using the OS
size. However, this should be clarified in the commit message.
The rest of the patch looks fine to me .
Cheers,
--
Julien Grall
next prev parent reply other threads:[~2021-05-17 18:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 8:35 [PATCH v3 0/5] Fix redefinition errors for toolstack libs Costin Lupu
2021-05-10 8:35 ` [PATCH v3 1/5] tools/debugger: Fix PAGE_SIZE redefinition error Costin Lupu
2021-05-11 6:35 ` Tim Deegan
2021-05-10 8:35 ` [PATCH v3 2/5] tools/libfsimage: Fix PATH_MAX " Costin Lupu
2021-05-10 8:35 ` [PATCH v3 3/5] tools/libs/foreignmemory: Fix PAGE_SIZE " Costin Lupu
2021-05-17 18:12 ` Julien Grall [this message]
2021-06-08 12:37 ` Costin Lupu
2021-05-10 8:35 ` [PATCH v3 4/5] tools/libs/gnttab: " Costin Lupu
2021-05-17 18:16 ` Julien Grall
2021-06-08 12:37 ` Costin Lupu
2021-05-10 8:35 ` [PATCH v3 5/5] tools/ocaml: Fix redefinition errors Costin Lupu
2021-05-17 18:16 ` Julien Grall
2021-05-19 14:03 ` Dario Faggioli
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=690806fb-e6e2-f61f-d7d6-a17efa6329d9@xen.org \
--to=julien@xen.org \
--cc=costin.lupu@cs.pub.ro \
--cc=iwj@xenproject.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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).