Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andrea Righi
Date: Wednesday, June 11, 2008 - 3:47 pm

Andrew Morton wrote:

No, it doesn't work. The problem seems to be in the PAGE_MASK definition
(from include/asm-x86/page.h for example):

/* PAGE_SHIFT determines the page size */
#define PAGE_SHIFT      12
#define PAGE_SIZE       (_AC(1,UL) << PAGE_SHIFT)
#define PAGE_MASK       (~(PAGE_SIZE-1))

The "~" is performed on a 32-bit value, so everything in "and" with
PAGE_MASK greater than 4GB will be truncated to the 32-bit boundary.

What do you think about the following?

#define PAGE_SIZE64 (1ULL << PAGE_SHIFT)
#define PAGE_MASK64 (~(PAGE_SIZE64 - 1))

#define PAGE_ALIGN(addr) ({					\
	typeof(addr) __size = PAGE_SIZE;			\
	typeof(addr) __ret = (addr) + __size - 1;		\
	__ret > -1UL ? __ret & PAGE_MASK64 : __ret & PAGE_MASK;	\
})

-Andrea
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[-mm][PATCH 0/4] Add memrlimit controller (v5), Balbir Singh, (Wed May 21, 8:29 am)
[-mm][PATCH 2/4] Setup the memrlimit controller (v5), Balbir Singh, (Wed May 21, 8:29 am)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Andrew Morton, (Wed May 21, 9:18 pm)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Andrea Righi, (Wed Jun 11, 10:10 am)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Balbir Singh, (Wed Jun 11, 10:33 am)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Andrea Righi, (Wed Jun 11, 11:48 am)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Andrew Morton, (Wed Jun 11, 12:15 pm)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Andrew Morton, (Wed Jun 11, 1:43 pm)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Andrea Righi, (Wed Jun 11, 3:47 pm)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Andrew Morton, (Wed Jun 11, 3:55 pm)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Balbir Singh, (Wed Jun 11, 11:13 pm)
Re: [-mm][PATCH 2/4] Setup the memrlimit controller (v5), Andrew Morton, (Thu Jun 12, 2:02 am)