From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759709Ab3DBDoi (ORCPT ); Mon, 1 Apr 2013 23:44:38 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:39418 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757413Ab3DBDoh (ORCPT ); Mon, 1 Apr 2013 23:44:37 -0400 Date: Mon, 1 Apr 2013 20:44:34 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Lin Feng cc: Zhouping Liu , Andrea Arcangeli , Hugh Dickins , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Amos Kong Subject: Re: THP: AnonHugePages in /proc/[pid]/smaps is correct or not? In-Reply-To: <515A5329.6020805@cn.fujitsu.com> Message-ID: References: <383590596.664138.1364803227470.JavaMail.root@redhat.com> <515A4BD1.1020407@redhat.com> <515A5329.6020805@cn.fujitsu.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2 Apr 2013, Lin Feng wrote: > > so, again, if I understand correctly, thp should tune the naturally aligned maps, such as generated by mmap()/malloc(), > > make such maps 'hugepagesize' aligned if the maps or vma is equal and greater than 'hugepagesize', doesn't it? > > We may gain performance improving from this. > To attain the maximum number of hugepages, you would naturally want to ensure that the mappings are done aligned to 2MB; for very large allocations, missing one or two hugepages typically won't hurt performance much. posix_memalign() is the best way of doing this which just wraps mmap() for the needed alignment. More interesting is creating your own custom malloc() that allocates in 2MB aligned chunks, if possible, and uses 2MB aligned arenas for its own metadata. If you do that for malloc(), then you'll only need to make code that does its own mmap()s to use posix_memalign(). From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx111.postini.com [74.125.245.111]) by kanga.kvack.org (Postfix) with SMTP id 673496B0002 for ; Mon, 1 Apr 2013 23:44:37 -0400 (EDT) Received: by mail-pa0-f50.google.com with SMTP id bg2so49356pad.23 for ; Mon, 01 Apr 2013 20:44:36 -0700 (PDT) Date: Mon, 1 Apr 2013 20:44:34 -0700 (PDT) From: David Rientjes Subject: Re: THP: AnonHugePages in /proc/[pid]/smaps is correct or not? In-Reply-To: <515A5329.6020805@cn.fujitsu.com> Message-ID: References: <383590596.664138.1364803227470.JavaMail.root@redhat.com> <515A4BD1.1020407@redhat.com> <515A5329.6020805@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Lin Feng Cc: Zhouping Liu , Andrea Arcangeli , Hugh Dickins , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Amos Kong On Tue, 2 Apr 2013, Lin Feng wrote: > > so, again, if I understand correctly, thp should tune the naturally aligned maps, such as generated by mmap()/malloc(), > > make such maps 'hugepagesize' aligned if the maps or vma is equal and greater than 'hugepagesize', doesn't it? > > We may gain performance improving from this. > To attain the maximum number of hugepages, you would naturally want to ensure that the mappings are done aligned to 2MB; for very large allocations, missing one or two hugepages typically won't hurt performance much. posix_memalign() is the best way of doing this which just wraps mmap() for the needed alignment. More interesting is creating your own custom malloc() that allocates in 2MB aligned chunks, if possible, and uses 2MB aligned arenas for its own metadata. If you do that for malloc(), then you'll only need to make code that does its own mmap()s to use posix_memalign(). -- 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/ . Don't email: email@kvack.org