[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 3/5] tools/libs/foreignmemory: Fix PAGE_SIZE redefinition error



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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.