Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751981AbbFZKic (ORCPT ); Fri, 26 Jun 2015 06:38:32 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:10187 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751902AbbFZKiY (ORCPT ); Fri, 26 Jun 2015 06:38:24 -0400 Message-ID: <558D2B8B.1060901@huawei.com> Date: Fri, 26 Jun 2015 18:38:03 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Kamezawa Hiroyuki CC: Andrew Morton , , Yinghai Lu , "H. Peter Anvin" , "Thomas Gleixner" , , Xiexiuqi , Hanjun Guo , "Luck, Tony" , Linux MM , LKML Subject: Re: [RFC PATCH 10/12] mm: add the buddy system interface References: <55704A7E.5030507@huawei.com> <55704CC4.8040707@huawei.com> <557691E0.5020203@jp.fujitsu.com> <5576BA2B.6060907@huawei.com> <5577A9A9.7010108@jp.fujitsu.com> <558BCD95.2090201@huawei.com> <558C94BB.1060304@jp.fujitsu.com> <558CAE43.4090702@huawei.com> <558D0E9B.8030405@jp.fujitsu.com> In-Reply-To: <558D0E9B.8030405@jp.fujitsu.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.558D2B9A.0196,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 51d9c3488dd5d28e4ad52ebf469d0786 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3761 Lines: 118 On 2015/6/26 16:34, Kamezawa Hiroyuki wrote: > On 2015/06/26 10:43, Xishi Qiu wrote: >> On 2015/6/26 7:54, Kamezawa Hiroyuki wrote: >> >>> On 2015/06/25 18:44, Xishi Qiu wrote: >>>> On 2015/6/10 11:06, Kamezawa Hiroyuki wrote: >>>> >>>>> On 2015/06/09 19:04, Xishi Qiu wrote: >>>>>> On 2015/6/9 15:12, Kamezawa Hiroyuki wrote: >>>>>> >>>>>>> On 2015/06/04 22:04, Xishi Qiu wrote: >>>>>>>> Add the buddy system interface for address range mirroring feature. >>>>>>>> Allocate mirrored pages in MIGRATE_MIRROR list. If there is no mirrored pages >>>>>>>> left, use other types pages. >>>>>>>> >>>>>>>> Signed-off-by: Xishi Qiu >>>>>>>> --- >>>>>>>> mm/page_alloc.c | 40 +++++++++++++++++++++++++++++++++++++++- >>>>>>>> 1 file changed, 39 insertions(+), 1 deletion(-) >>>>>>>> >>>>>>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >>>>>>>> index d4d2066..0fb55288 100644 >>>>>>>> --- a/mm/page_alloc.c >>>>>>>> +++ b/mm/page_alloc.c >>>>>>>> @@ -599,6 +599,26 @@ static inline bool is_mirror_pfn(unsigned long pfn) >>>>>>>> >>>>>>>> return false; >>>>>>>> } >>>>>>>> + >>>>>>>> +static inline bool change_to_mirror(gfp_t gfp_flags, int high_zoneidx) >>>>>>>> +{ >>>>>>>> + /* >>>>>>>> + * Do not alloc mirrored memory below 4G, because 0-4G is >>>>>>>> + * all mirrored by default, and the list is always empty. >>>>>>>> + */ >>>>>>>> + if (high_zoneidx < ZONE_NORMAL) >>>>>>>> + return false; >>>>>>>> + >>>>>>>> + /* Alloc mirrored memory for only kernel */ >>>>>>>> + if (gfp_flags & __GFP_MIRROR) >>>>>>>> + return true; >>>>>>> >>>>>>> GFP_KERNEL itself should imply mirror, I think. >>>>>>> >>>>>> >>>>>> Hi Kame, >>>>>> >>>>>> How about like this: #define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_MIRROR) ? >>>>>> >>>>> >>>>> Hm.... it cannot cover GFP_ATOMIC at el. >>>>> >>>>> I guess, mirrored memory should be allocated if !__GFP_HIGHMEM or !__GFP_MOVABLE >>>> >>>> >>>> Hi Kame, >>>> >>>> Can we distinguish allocations form user or kernel only by GFP flags? >>>> >>> >>> Allocation from user and file caches are now *always* done with __GFP_MOVABLE. >>> >>> By this, pages will be allocated from MIGRATE_MOVABLE migration type. >>> MOVABLE migration type means it's can >>> be the target for page compaction or memory-hot-remove. >>> >>> Thanks, >>> -Kame >>> >> >> So if we want all kernel memory allocated from mirror, how about change like this? >> __alloc_pages_nodemask() >> gfpflags_to_migratetype() >> if (!(gfp_mask & __GFP_MOVABLE)) >> return MIGRATE_MIRROR > > Maybe used with jump label can reduce performance impact. Hi Kame, I am not understand jump label, but I wil try. > == > static inline bool memory_mirror_enabled(void) > { > return static_key_false(&memory_mirror_enabled); > } > > > > gfpflags_to_migratetype() > if (memory_mirror_enabled()) { /* We want to mirror all unmovable pages */ > if (!(gfp_mask & __GFP_MOVABLE)) > return MIGRATE_MIRROR > } > == > > BTW, I think current memory compaction code scans ranges of MOVABLE migrate type. > So, if you use other migration type than MOVABLE for user pages, you may see > page fragmentation. If you want to expand this MIRROR to user pages, please check > mm/compaction.c > As Tony said "how can we minimize the run-time impact on systems that don't have any mirrored memory.", I think the idea "kernel only from MIRROR / user only from MOVABLE" may be better. Thanks, Xishi Qiu -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/