From: Michal Nazarewicz Subject: Re: [PATCH] [RFC] CMA: clear buffer-head lru before page migration Date: Tue, 08 Jul 2014 18:46:31 +0200 Message-ID: References: <53B664E5.5060102@lge.com> <20140707155252.15e81dff6683393ba3590478@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Laura Abbott , Marek Szyprowski , Joonsoo Kim , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?B?7J206rG07Zi4?= , Gi-Oh Kim , Marek Szyprowski To: Andrew Morton , Gioh Kim Return-path: Received: from mail-we0-f180.google.com ([74.125.82.180]:63746 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753642AbaGHQqg convert rfc822-to-8bit (ORCPT ); Tue, 8 Jul 2014 12:46:36 -0400 Received: by mail-we0-f180.google.com with SMTP id x48so6221340wes.39 for ; Tue, 08 Jul 2014 09:46:34 -0700 (PDT) In-Reply-To: <20140707155252.15e81dff6683393ba3590478@linux-foundation.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Jul 07 2014, Andrew Morton wrote: > What I proposed is that CMA call invalidate_bh_lrus() right at the > outset. Something along the lines of > > --- a/mm/page_alloc.c~a > +++ a/mm/page_alloc.c > @@ -6329,6 +6329,14 @@ int alloc_contig_range(unsigned long sta > }; > INIT_LIST_HEAD(&cc.migratepages); > =20 > +#ifdef CONFIG_CMA > + /* > + * Comment goes here > + */ > + if (migratetype =3D=3D MIGRATE_CMA) > + invalidate_bh_lrus(); > +#endif > + This seems reasonable, except I think it should go after start_isolate_page_range call because otherwise there's no guarantee that someone won't grab those pages back. Also to avoid the #ifdef perhaps we want this as well: diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 6cbd1b6..2640a55 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -64,10 +64,11 @@ enum { }; =20 #ifdef CONFIG_CMA -# define is_migrate_cma(migratetype) unlikely((migratetype) =3D=3D MI= GRATE_CMA) +# define __is_migrate_cma(migratetype) ((migratetype) =3D=3D MIGRATE_= CMA) #else -# define is_migrate_cma(migratetype) false +# define __is_migrate_cma(migratetype) false #endif +#define is_migrate_cma(migratetype) unlikely(__is_migrate_cma(migratet= ype)) =20 #define for_each_migratetype_order(order, type) \ for (order =3D 0; order < MAX_ORDER; order++) \ and then use =E2=80=9Cif (__is_migrate_cma(migratetype))=E2=80=9D. > /* > * What we do here is we mark all pageblocks in range as > * MIGRATE_ISOLATE. Because pageblock and max order pages may > > > - I'd have thought that it would make sense to do this for huge pages > as well (MIGRATE_MOVABLE) but nobody really seems to know. > > - There's a patch floating around ("Allow increasing the buffer-head > per-CPU LRU size") which will double the size of the bh lrus, so th= is > all becomes more important. > > - alloc_contig_range() does lru_add_drain_all() and drain_all_pages() > *after* performing the allocation. I can't work out why this is th= e > case and of course it is undocumented. If this is indeed not a bug > then probably the invalidate_bh_lrus() should happen in the same > place. The purpose is to get free non-buddy pages (so pages on PCP lists for instance) back onto the buddy list. It's safe to move those calls abov= e the call to __alloc_contig_migrate_range, but I don't think it will change anything (except of course the fact that if migration fails, we'll do the draining for nothing). --=20 Best regards, _ _ =2Eo. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o =2E.o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarew= icz (o o) ooo +------ooO--(_)--Ooo-- -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html