Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751952AbdGEQDj (ORCPT ); Wed, 5 Jul 2017 12:03:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44910 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751681AbdGEQDi (ORCPT ); Wed, 5 Jul 2017 12:03:38 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 05 Jul 2017 13:03:57 -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: <1f549637-773a-868c-effd-5614e85aa892@linux.vnet.ibm.com> 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: 17070516-0020-0000-0000-00000C4E1AA4 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007324; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00883251; UDB=6.00440608; IPR=6.00663443; BA=6.00005454; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016094; XFM=3.00000015; UTC=2017-07-05 16:03:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070516-0021-0000-0000-00005D1B1BD6 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-05_10:,, 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-1703280000 definitions=main-1707050269 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2339 Lines: 71 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