Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751356AbdCID00 (ORCPT ); Wed, 8 Mar 2017 22:26:26 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52073 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750805AbdCID0X (ORCPT ); Wed, 8 Mar 2017 22:26:23 -0500 Subject: Re: [PATCH] mm,hugetlb: compute page_size_log properly To: Andi Kleen , Davidlohr Bueso References: <1488992761-9464-1-git-send-email-dave@stgolabs.net> <20170308193900.GC32070@tassilo.jf.intel.com> Cc: akpm@linux-foundation.org, mhocko@suse.com, mtk.manpages@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Davidlohr Bueso From: Anshuman Khandual Date: Thu, 9 Mar 2017 08:54:55 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170308193900.GC32070@tassilo.jf.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 17030903-0052-0000-0000-000002209A2D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030903-0053-0000-0000-000007EE70D6 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-09_02:,, 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-1702020001 definitions=main-1703090027 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1699 Lines: 46 On 03/09/2017 01:09 AM, Andi Kleen wrote: >> One example of the problems with extra layers what this patch fixes: >> mmap_pgoff() should never be using SHM_HUGE_* logic. This was >> introduced by: >> >> 091d0d55b28 (shm: fix null pointer deref when userspace specifies invalid hugepage size) >> >> It is obviously harmless but lets just rip out the whole thing -- >> the shmget.2 manpage will need updating, as it should not be >> describing kernel internals. > > The SHM_* defines were supposed to be exported to user space, > but somehow they didn't make it into uapi. Yeah, its not part of UAPI which it should have been. Now we need to ilog2(page_size) and shift it before using them in the user space. BTW, mmap() interface also would want this encoding should we choose to use non default HugeTLB page sizes. > > But something like this is useful, it's a much nicer > interface for users than to hard code the bit position Right. But as we need this both for shm and mmap() interface, we can only have one set of values exported to the UAPI. The other set needs to be removed IMHO. BTW, we need to add the encoding for other arch supported HugeTLB supported sizes as well like 16MB, 16GB etc (on POWER). > > So I would rather if you move it to uapi instead of > removing. What the kernel uses internally doesn't > really matter. Had a sent a clean up patch last year which unfortunately I forgot to resend though it has got ACK from Michal Hocko and Balbir Singh. https://lkml.org/lkml/2016/4/7/43 I had also tried to add POWER HugeTLB size encoding in the arch specific header files. Probably its time to move all of them to generic header. https://lkml.org/lkml/2016/4/7/48