From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail172.messagelabs.com (mail172.messagelabs.com [216.82.254.3]) by kanga.kvack.org (Postfix) with ESMTP id 02B678D003B for ; Tue, 19 Apr 2011 14:02:54 -0400 (EDT) Received: from hpaq12.eem.corp.google.com (hpaq12.eem.corp.google.com [172.25.149.12]) by smtp-out.google.com with ESMTP id p3JI2p0X018304 for ; Tue, 19 Apr 2011 11:02:51 -0700 Received: from qyk35 (qyk35.prod.google.com [10.241.83.163]) by hpaq12.eem.corp.google.com with ESMTP id p3JI2DPq024180 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 19 Apr 2011 11:02:50 -0700 Received: by qyk35 with SMTP id 35so1805731qyk.13 for ; Tue, 19 Apr 2011 11:02:49 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1303235496-3060-3-git-send-email-yinghan@google.com> References: <1303235496-3060-1-git-send-email-yinghan@google.com> <1303235496-3060-3-git-send-email-yinghan@google.com> Date: Tue, 19 Apr 2011 11:02:48 -0700 Message-ID: Subject: Re: [PATCH 2/3] change the shrink_slab by passing scan_control. From: Ying Han Content-Type: multipart/alternative; boundary=00248c6a84cadbe31604a1495052 Sender: owner-linux-mm@kvack.org List-ID: To: Nick Piggin , KOSAKI Motohiro , Minchan Kim , Daisuke Nishimura , Balbir Singh , Tejun Heo , Pavel Emelyanov , KAMEZAWA Hiroyuki , Andrew Morton , Li Zefan , Mel Gorman , Christoph Lameter , Johannes Weiner , Rik van Riel , Hugh Dickins , Michal Hocko , Dave Hansen , Zhu Yanhai Cc: linux-mm@kvack.org --00248c6a84cadbe31604a1495052 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Apr 19, 2011 at 10:51 AM, Ying Han wrote: > This patch consolidates existing parameters to shrink_slab() to > scan_control struct. This is needed later to pass the same struct > to shrinkers. > > Signed-off-by: Ying Han > --- > fs/drop_caches.c | 7 ++++++- > include/linux/mm.h | 4 ++-- > mm/vmscan.c | 12 ++++++------ > 3 files changed, 14 insertions(+), 9 deletions(-) > > diff --git a/fs/drop_caches.c b/fs/drop_caches.c > index 816f88e..0e5ef62 100644 > --- a/fs/drop_caches.c > +++ b/fs/drop_caches.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > > /* A global variable is a bit ugly, but it keeps the code simple */ > int sysctl_drop_caches; > @@ -36,9 +37,13 @@ static void drop_pagecache_sb(struct super_block *sb, > void *unused) > static void drop_slab(void) > { > int nr_objects; > + struct scan_control sc = { > + .gfp_mask = GFP_KERNEL, > + .nr_scanned = 1000, > + }; > > do { > - nr_objects = shrink_slab(1000, GFP_KERNEL, 1000); > + nr_objects = shrink_slab(&sc, 1000); > } while (nr_objects > 10); > } > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 0716517..42c2bf4 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -21,6 +21,7 @@ struct anon_vma; > struct file_ra_state; > struct user_struct; > struct writeback_control; > +struct scan_control; > > #ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly > */ > extern unsigned long max_mapnr; > @@ -1601,8 +1602,7 @@ int in_gate_area_no_task(unsigned long addr); > > int drop_caches_sysctl_handler(struct ctl_table *, int, > void __user *, size_t *, loff_t *); > -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, > - unsigned long lru_pages); > +unsigned long shrink_slab(struct scan_control *sc, unsigned long > lru_pages); > > #ifndef CONFIG_MMU > #define randomize_va_space 0 > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 08b1ab5..9662166 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -159,11 +159,12 @@ EXPORT_SYMBOL(unregister_shrinker); > * > * Returns the number of slab objects which we shrunk. > */ > -unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask, > - unsigned long lru_pages) > +unsigned long shrink_slab(struct scan_control *sc, unsigned long > lru_pages) > { > struct shrinker *shrinker; > unsigned long ret = 0; > + unsigned long scanned = sc->nr_scanned; > + gfp_t gfp_mask = sc->gfp_mask; > > if (scanned == 0) > scanned = SWAP_CLUSTER_MAX; > @@ -2005,7 +2006,7 @@ static unsigned long do_try_to_free_pages(struct > zonelist *zonelist, > lru_pages += zone_reclaimable_pages(zone); > } > > - shrink_slab(sc->nr_scanned, sc->gfp_mask, > lru_pages); > + shrink_slab(sc, lru_pages); > if (reclaim_state) { > sc->nr_reclaimed += > reclaim_state->reclaimed_slab; > reclaim_state->reclaimed_slab = 0; > @@ -2371,8 +2372,7 @@ loop_again: > end_zone, 0)) > shrink_zone(priority, zone, &sc); > reclaim_state->reclaimed_slab = 0; > - nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL, > - lru_pages); > + nr_slab = shrink_slab(&sc, lru_pages); > sc.nr_reclaimed += reclaim_state->reclaimed_slab; > total_scanned += sc.nr_scanned; > > @@ -2949,7 +2949,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t > gfp_mask, unsigned int order) > unsigned long lru_pages = > zone_reclaimable_pages(zone); > > /* No reclaimable slab or very low memory pressure > */ > - if (!shrink_slab(sc.nr_scanned, gfp_mask, > lru_pages)) > + if (!shrink_slab(&sc, lru_pages)) > break; > > /* Freed enough memory */ > -- > 1.7.3.1 > > --00248c6a84cadbe31604a1495052 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Tue, Apr 19, 2011 at 10:51 AM, Ying H= an <yinghan@goog= le.com> wrote:
This patch consolidates existing parameters to shrink_slab() to
scan_control struct. This is needed later to pass the same struct
to shrinkers.

Signed-off-by: Ying Han <yinghan@g= oogle.com>
---
=A0fs/drop_caches.c =A0 | =A0 =A07 ++++++-
=A0include/linux/mm.h | =A0 =A04 ++--
=A0mm/vmscan.c =A0 =A0 =A0 =A0| =A0 12 ++++++------
=A03 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index 816f88e..0e5ef62 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -8,6 +8,7 @@
=A0#include <linux/writeback.h>
=A0#include <linux/sysctl.h>
=A0#include <linux/gfp.h>
+#include <linux/swap.h>

=A0/* A global variable is a bit ugly, but it keeps the code simple */
=A0int sysctl_drop_caches;
@@ -36,9 +37,13 @@ static void drop_pagecache_sb(struct super_block *sb, vo= id *unused)
=A0static void drop_slab(void)
=A0{
=A0 =A0 =A0 =A0int nr_objects;
+ =A0 =A0 =A0 struct scan_control sc =3D {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 .gfp_mask =3D GFP_KERNEL,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 .nr_scanned =3D 1000,
+ =A0 =A0 =A0 };

=A0 =A0 =A0 =A0do {
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 nr_objects =3D shrink_slab(1000, GFP_KERNEL, = 1000);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 nr_objects =3D shrink_slab(&sc, 1000); =A0 =A0 =A0 =A0} while (nr_objects > 10);
=A0}

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0716517..42c2bf4 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -21,6 +21,7 @@ struct anon_vma;
=A0struct file_ra_state;
=A0struct user_struct;
=A0struct writeback_control;
+struct scan_control;

=A0#ifndef CONFIG_DISCONTIGMEM =A0 =A0 =A0 =A0 =A0/* Don't use mapnrs, = do it properly */
=A0extern unsigned long max_mapnr;
@@ -1601,8 +1602,7 @@ int in_gate_area_no_task(unsigned long addr);

=A0int drop_caches_sysctl_handler(struct ctl_table *, int,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0void __user *, size_t *, loff_t *);
-unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned long lru_pages);
+unsigned long shrink_slab(struct scan_control *sc, unsigned long lru_pages= );

=A0#ifndef CONFIG_MMU
=A0#define randomize_va_space 0
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 08b1ab5..9662166 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -159,11 +159,12 @@ EXPORT_SYMBOL(unregister_shrinker);
=A0*
=A0* Returns the number of slab objects which we shrunk.
=A0*/
-unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned long lru_pages)
+unsigned long shrink_slab(struct scan_control *sc, unsigned long lru_pages= )
=A0{
=A0 =A0 =A0 =A0struct shrinker *shrinker;
=A0 =A0 =A0 =A0unsigned long ret =3D 0;
+ =A0 =A0 =A0 unsigned long scanned =3D sc->nr_scanned;
+ =A0 =A0 =A0 gfp_t gfp_mask =3D sc->gfp_mask;

=A0 =A0 =A0 =A0if (scanned =3D=3D 0)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0scanned =3D SWAP_CLUSTER_MAX;
@@ -2005,7 +2006,7 @@ static unsigned long do_try_to_free_pages(struct zone= list *zonelist,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0lru_pages += =3D zone_reclaimable_pages(zone);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0}

- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 shrink_slab(sc->nr_scanned= , sc->gfp_mask, lru_pages);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 shrink_slab(sc, lru_pages); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (reclaim_state) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sc->nr_r= eclaimed +=3D reclaim_state->reclaimed_slab;
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reclaim_sta= te->reclaimed_slab =3D 0;
@@ -2371,8 +2372,7 @@ loop_again:
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0end_zone, 0))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0shrink_zone= (priority, zone, &sc);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reclaim_state->reclaimed= _slab =3D 0;
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nr_slab =3D shrink_slab(sc.nr= _scanned, GFP_KERNEL,
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 lru_pages);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nr_slab =3D shrink_slab(&= sc, lru_pages);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sc.nr_reclaimed +=3D reclai= m_state->reclaimed_slab;
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0total_scanned +=3D sc.nr_sc= anned;

@@ -2949,7 +2949,7 @@ static int __zone_reclaim(struct zone *zone, gfp_t gf= p_mask, unsigned int order)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unsigned long lru_pages =3D= zone_reclaimable_pages(zone);

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* No reclaimable slab or v= ery low memory pressure */
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!shrink_slab(sc.nr_scanne= d, gfp_mask, lru_pages))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!shrink_slab(&sc, lru= _pages))
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Freed enough memory */ --
1.7.3.1


--00248c6a84cadbe31604a1495052-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org