xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Costin Lupu <costin.lupu@cs.pub.ro>
To: Julien Grall <julien@xen.org>, 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: Tue, 8 Jun 2021 15:37:23 +0300	[thread overview]
Message-ID: <153d38e4-b5fe-3530-138e-ad116a7c4c4c@cs.pub.ro> (raw)
In-Reply-To: <690806fb-e6e2-f61f-d7d6-a17efa6329d9@xen.org>

Hi Julien,

On 5/17/21 9:12 PM, Julien Grall wrote:
> 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?
> 

I think it would be safer to follow the man page indication. I've just
sent a v4.

>>   -        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.
> 

Done.

> The rest of the patch looks fine to me .

Thanks,
Costin


  reply	other threads:[~2021-06-08 12:37 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
2021-06-08 12:37     ` Costin Lupu [this message]
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=153d38e4-b5fe-3530-138e-ad116a7c4c4c@cs.pub.ro \
    --to=costin.lupu@cs.pub.ro \
    --cc=iwj@xenproject.org \
    --cc=julien@xen.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).