Skip to contentSkip to conversation

arch: uapi: asm: mman.h: Support MADV_FREE for madvise()

PATCH In review Chen Gang 5 participants 7 messages Dec 1, 2014 – Dec 2, 2014

Subsystems (4)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 arch: uapi: asm: mman.h: Support MADV_FREE for madvise()

At present, kernel supports madvise(MADV_FREE), so can benefit to all related architectures (can grep MADV_WILLNEED or MADV_REMOVE in "arch/" to know about all related architectures).

The related git commit: "4fb10ba mm: support madvise(MADV_FREE)".

The related error (with allmodconfig under parisc):

CC mm/madvise.o
mm/madvise.c: In function 'madvise_need_mmap_write':
mm/madvise.c:42:7: error: 'MADV_FREE' undeclared (first use in this function)

    case MADV_FREE:
       ^
  mm/madvise.c:42:7: note: each undeclared identifier is reported only once for each function it appears in
  mm/madvise.c: In function 'madvise_vma':
  mm/madvise.c:534:7: error: 'MADV_FREE' undeclared (first use in this function)
    case MADV_FREE:
       ^
  mm/madvise.c: In function 'madvise_behavior_valid':
  mm/madvise.c:561:7: error: 'MADV_FREE' undeclared (first use in this function)
    case MADV_FREE:
       ^

make[1]: *** [mm/madvise.o] Error 1
make: *** [mm] Error 2

---
 arch/alpha/include/uapi/asm/mman.h  | 1 +
 arch/mips/include/uapi/asm/mman.h   | 1 +
 arch/parisc/include/uapi/asm/mman.h | 1 +
 arch/xtensa/include/uapi/asm/mman.h | 1 +
 4 files changed, 4 insertions(+)
arch/alpha/include/uapi/asm/mman.h +1 -0
index 0086b47..836fbd4 100644
@@ -44,6 +44,7 @@
 #define MADV_WILLNEED	3		/* will need these pages */
 #define	MADV_SPACEAVAIL	5		/* ensure resources are available */
 #define MADV_DONTNEED	6		/* don't need these pages */
+#define MADV_FREE	7		/* free pages only if memory pressure */
 
 /* common/generic parameters */
 #define MADV_REMOVE	9		/* remove these pages & resources */
arch/mips/include/uapi/asm/mman.h +1 -0
index cfcb876..106e741 100644
@@ -67,6 +67,7 @@
 #define MADV_SEQUENTIAL 2		/* expect sequential page references */
 #define MADV_WILLNEED	3		/* will need these pages */
 #define MADV_DONTNEED	4		/* don't need these pages */
+#define MADV_FREE	5		/* free pages only if memory pressure */
 
 /* common parameters: try to keep these consistent across architectures */
 #define MADV_REMOVE	9		/* remove these pages & resources */
arch/parisc/include/uapi/asm/mman.h +1 -0
index 294d251..6cb8db7 100644
@@ -40,6 +40,7 @@
 #define MADV_SPACEAVAIL 5               /* insure that resources are reserved */
 #define MADV_VPS_PURGE  6               /* Purge pages from VM page cache */
 #define MADV_VPS_INHERIT 7              /* Inherit parents page size */
+#define MADV_FREE	8		/* free pages only if memory pressure */
 
 /* common/generic parameters */
 #define MADV_REMOVE	9		/* remove these pages & resources */
arch/xtensa/include/uapi/asm/mman.h +1 -0
index 201aec0..1b19f25 100644
@@ -80,6 +80,7 @@
 #define MADV_SEQUENTIAL	2		/* expect sequential page references */
 #define MADV_WILLNEED	3		/* will need these pages */
 #define MADV_DONTNEED	4		/* don't need these pages */
+#define MADV_FREE	5		/* free pages only if memory pressure */
 
 /* common parameters: try to keep these consistent across architectures */
 #define MADV_REMOVE	9		/* remove these pages & resources */
Signature · 1 line
1.9.3
maintainer
#1 lore raw
Quoted 3 lines · Chen Gang

At present, kernel supports madvise(MADV_FREE), so can benefit to all related architectures (can grep MADV_WILLNEED or MADV_REMOVE in "arch/" to know about all related architectures).

A similar patch has been posted a while ago:

http://www.spinics.net/lists/linux-mm/msg81538.html

Signature · 2 lines
Thanks.
-- Max
#2 lore raw
Quoted 8 lines · Max Filippov
Quoted 3 lines · Chen Gang

At present, kernel supports madvise(MADV_FREE), so can benefit to all related architectures (can grep MADV_WILLNEED or MADV_REMOVE in "arch/" to know about all related architectures).

A similar patch has been posted a while ago:

http://www.spinics.net/lists/linux-mm/msg81538.html

Would it be possible to use the same number everywhere?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#3 lore raw
Quoted 11 lines · Geert Uytterhoeven
Quoted 8 lines · Max Filippov
Quoted 3 lines · Chen Gang

At present, kernel supports madvise(MADV_FREE), so can benefit to all related architectures (can grep MADV_WILLNEED or MADV_REMOVE in "arch/" to know about all related architectures).

A similar patch has been posted a while ago:

http://www.spinics.net/lists/linux-mm/msg81538.html

Would it be possible to use the same number everywhere?

Yes please. It's ridiculous that we still need patches like this.

I proposed unifying all this two years ago, but didn't follow up.

From glibc's perspective it would be simpler if we started using the same number everywhere.

http://www.spinics.net/lists/linux-api/msg02064.html

Cheers,
Carlos.

author
#4 lore raw
Quoted 11 lines · Carlos O'Donell
Quoted 10 lines · Geert Uytterhoeven
Quoted 8 lines · Max Filippov
Quoted 3 lines · Chen Gang

At present, kernel supports madvise(MADV_FREE), so can benefit to all related architectures (can grep MADV_WILLNEED or MADV_REMOVE in "arch/" to know about all related architectures).

A similar patch has been posted a while ago:

http://www.spinics.net/lists/linux-mm/msg81538.html

OK, thanks.

Quoted 2 lines
Quoted 1 line

Would it be possible to use the same number everywhere?

For current patch, I guess, we can use '8' for it, since MADV_FREE in asm-generic is merged just a few days ago (which is not used by user mode), and parisc has to use '8'.

And welcome the related member's ideas.

Quoted 9 lines

Yes please. It's ridiculous that we still need patches like this.

I proposed unifying all this two years ago, but didn't follow up.

From glibc's perspective it would be simpler if we started using the same number everywhere.

http://www.spinics.net/lists/linux-api/msg02064.html

For me, we can divide it into 2 steps:

- Let MADV_FREE has the same value (about current patch).

- Let all shared MADV_* to "asm-generic" (about next patch, although I am not quite sure whether it is executable).

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed
maintainer
#5 lore raw
In reply to Carlos O'Donell
Quoted 13 lines · Carlos O'Donell
Quoted 11 lines · Geert Uytterhoeven
Quoted 8 lines · Max Filippov
Quoted 3 lines · Chen Gang

At present, kernel supports madvise(MADV_FREE), so can benefit to all related architectures (can grep MADV_WILLNEED or MADV_REMOVE in "arch/" to know about all related architectures).

A similar patch has been posted a while ago:

http://www.spinics.net/lists/linux-mm/msg81538.html

Would it be possible to use the same number everywhere?

Quoted 8 lines

Yes please. It's ridiculous that we still need patches like this.

I proposed unifying all this two years ago, but didn't follow up.

From glibc's perspective it would be simpler if we started using the same number everywhere.

http://www.spinics.net/lists/linux-api/msg02064.html

Please co-ordinate with Andrew then because he's intent on merging this patch:

http://marc.info/?l=linux-mm-commits&m=141747572930808

James

author
#6 lore raw
Quoted 21 lines · James Bottomley
Quoted 20 lines · Carlos O'Donell
Quoted 11 lines · Geert Uytterhoeven
Quoted 8 lines · Max Filippov
Quoted 3 lines · Chen Gang

At present, kernel supports madvise(MADV_FREE), so can benefit to all related architectures (can grep MADV_WILLNEED or MADV_REMOVE in "arch/" to know about all related architectures).

A similar patch has been posted a while ago:

http://www.spinics.net/lists/linux-mm/msg81538.html

Would it be possible to use the same number everywhere?

Yes please. It's ridiculous that we still need patches like this.

I proposed unifying all this two years ago, but didn't follow up.

From glibc's perspective it would be simpler if we started using the same number everywhere.

Quoted 7 lines
Quoted 1 line

http://www.spinics.net/lists/linux-api/msg02064.html

Please co-ordinate with Andrew then because he's intent on merging this patch:

http://marc.info/?l=linux-mm-commits&m=141747572930808

For me, we can let MADV_FREE to 8 based on the Andrew's mm tree. Since it is about uapi, we need try our best to let it perfect.

Thanks.

Signature · 3 lines
Chen Gang

Open, share, and attitude like air, water, and life which God blessed