Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753070AbdGLPOc (ORCPT ); Wed, 12 Jul 2017 11:14:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55498 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752735AbdGLPOb (ORCPT ); Wed, 12 Jul 2017 11:14:31 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 12 Jul 2017 12:15:10 -0300 From: victora To: "Aneesh Kumar K.V" Cc: Victor Aoqui , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au Subject: Re: [PATCH] powerpc/mm: Implemented default_hugepagesz verification for powerpc In-Reply-To: References: <20170703200559.3743-1-victora@br.ibm.com> <1f549637-773a-868c-effd-5614e85aa892@linux.vnet.ibm.com> User-Agent: Roundcube Webmail/1.0.1 X-TM-AS-GCONF: 00 x-cbid: 17071215-0012-0000-0000-000014A6E61F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007355; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00886544; UDB=6.00442545; IPR=6.00666693; BA=6.00005468; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016198; XFM=3.00000015; UTC=2017-07-12 15:14:28 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071215-0013-0000-0000-00004E90BFC5 Message-Id: <231a6e252020968b7eff8dd25dbb126b@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-12_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707120244 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2534 Lines: 80 Em 2017-07-05 13:03, victora escreveu: > Em 2017-07-05 01:26, Aneesh Kumar K.V escreveu: >> On Tuesday 04 July 2017 01:35 AM, Victor Aoqui wrote: >>> Implemented default hugepage size verification (default_hugepagesz=) >>> in order to allow allocation of defined number of pages (hugepages=) >>> only for supported hugepage sizes. >>> >>> Signed-off-by: Victor Aoqui >>> --- >>> arch/powerpc/mm/hugetlbpage.c | 15 +++++++++++++++ >>> 1 file changed, 15 insertions(+) >>> >>> diff --git a/arch/powerpc/mm/hugetlbpage.c >>> b/arch/powerpc/mm/hugetlbpage.c >>> index a4f33de..464e72e 100644 >>> --- a/arch/powerpc/mm/hugetlbpage.c >>> +++ b/arch/powerpc/mm/hugetlbpage.c >>> @@ -797,6 +797,21 @@ static int __init hugepage_setup_sz(char *str) >>> } >>> __setup("hugepagesz=", hugepage_setup_sz); >>> >>> +static int __init default_hugepage_setup_sz(char *str) >>> +{ >>> + unsigned long long size; >>> + >>> + size = memparse(str, &str); >>> + >>> + if (add_huge_page_size(size) != 0) { >>> + hugetlb_bad_size(); >>> + pr_err("Invalid default huge page size >>> specified(%llu)\n", size); >>> + } >>> + >>> + return 1; >>> +} >>> +__setup("default_hugepagesz=", default_hugepage_setup_sz); >> >> isn't that a behavior change in what we have now ? . Right now if size >> specified is not supported, we fallback to HPAGE_SIZE. > > Yes, it is. However, is this a correct behavior? If we specify an > unsupported value, for example default_hugepagesz=1M and > hugepages=1000, 1M will be ignored and 1000 pages of 16M (arch > default) will be allocated. This could lead to non-expected out of of > memory/performance issue. > >> >> mm/hugetlb.c >> >> if (!size_to_hstate(default_hstate_size)) { >> default_hstate_size = HPAGE_SIZE; >> if (!size_to_hstate(default_hstate_size)) >> hugetlb_add_hstate(HUGETLB_PAGE_ORDER); >> } >> >> >>> + >>> struct kmem_cache *hugepte_cache; >>> static int __init hugetlbpage_init(void) >>> { >>> >> >> Even if we want to do this, this should be done in generic code and >> should not be powerpc specific >> > > The verification of supported powerpc hugepage size (hugepagesz=) is > being performed on add_huge_page_size(), which is currently defined in > arch/powerpc/mm/hugetlbpage.c. I think it makes more sense to > implement default_hugepagesz= verification on arch/powerpc, don't you > think? > >> -aneesh Hi Aneesh, Did you have time to review the comments above? Thanks Victor