Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3704124imu; Mon, 14 Jan 2019 07:38:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN5ZSvzI31KevyMyEAPKNLrsizHcIGVie+oxBtRg0urA9l7zZe+gjhYNdQBHgc733xf2MGnp X-Received: by 2002:a17:902:2006:: with SMTP id n6mr26418008pla.66.1547480337310; Mon, 14 Jan 2019 07:38:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547480337; cv=none; d=google.com; s=arc-20160816; b=L5RgHuBiyIZyap3SjKDssKb4hH/WyqIrDcFq14nUpVJC/7ZecFw3uWfyLjD7MiQOrC KF63NhEMzrKJzrgmMqz1PJoPGDjOOUkkqp5vS2yCqIjTCIa2ot8v0Ya6yQecYKqwVrbs wIfGEDSdCZwK1cn2D4jl5NIYpCkazF69neGeFd1AbflK5/YjAM+1TQMuQIzcBQc5SNo2 dJT1OT0oxXxdBE6rIDfgV803aC5uLyy3xVrsnlQx74PqfbwZvW2e8te7KKoRLAMr2dFr eD+1AyTO4G35ziLvM+xRL2qeTweMaxnQPLFdBhmDJQ/l7Ima+lWkzKB9G1OkoxQ+K9PP 8k/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=wAbku0n0ZmnKcGbXvkVv10iFzXXgTeSrZJjX6nGCyc8=; b=urrsHB4HiEzM1SmmlWlBT1wKcObXpyHIENVgxiKXmyXJOoTJqg+kysgeDKorWaWj2Y LSJcL6M9AefwJ1/4h9GorHwfLlzdXHm5ZEpaeQ92Kfcvwm/gxhi1cH+lweebQh6cC7oj HNXAWOqqDKF3sX12BhqB2G/48F0uNhET0Q9ar90jfDb772v3iiKAMXaF5mGN6/Aq+cyq bR8z2qW3JMHp3C6ktiID1HqbekvWMXP+lfFxcKA+lrCAd54NX0aXauF1kD/FNJ3I2ST9 S9A931htIKHSR+Y/Nno4Xrdf8LTCp/hQmNNNoG/t6VamA8++gLwjiwgACoiyybkgzPTp Y1uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=EIk35YtV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m8si597549pgb.58.2019.01.14.07.38.41; Mon, 14 Jan 2019 07:38:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=EIk35YtV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726824AbfANPgS (ORCPT + 99 others); Mon, 14 Jan 2019 10:36:18 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:54776 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbfANPgS (ORCPT ); Mon, 14 Jan 2019 10:36:18 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0EFSx49011678; Mon, 14 Jan 2019 15:35:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=wAbku0n0ZmnKcGbXvkVv10iFzXXgTeSrZJjX6nGCyc8=; b=EIk35YtVk8irMk4hsG89g1ZIM20NLKjuN6nCgHT1QM/i1vgAct3TpckB1iU7VR4MTwij ZjX/KnVVt+tFVY5qvlPImti8jcQo4xiVy1zn/7xNgO8McDoaSFxh/Dc7zIQxQfADV0am zuqz9cdwYVRDlWMgNBMAHXSm58AAw/cAUBh+ezc1hSxhid8r+AgOzCp725R3O12rF4CS vHswtCSV1/0KURlkh+U2iF0UfqiwY9ruk6ZvkRB+gjjLV6dbXGwmLAKLUeuxbEUyed6A w8736AnRkbRkCBtDtdHfKrQSAo4Apl5S6bS4pvxC3XDPJyQplOSsdCM6NjJ+50iMVOFj yg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2pybkc65a5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Jan 2019 15:35:59 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0EFZshU010907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Jan 2019 15:35:54 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0EFZr3G015840; Mon, 14 Jan 2019 15:35:53 GMT Received: from [10.152.35.100] (/10.152.35.100) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 14 Jan 2019 07:35:52 -0800 Subject: Re: [RFC PATCH] mm: align anon mmap for THP To: Mike Kravetz , "Kirill A. Shutemov" , linux_lkml_grp@oracle.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Michal Hocko , Dan Williams , Matthew Wilcox , Toshi Kani , Boaz Harrosh , Andrew Morton References: <20190111201003.19755-1-mike.kravetz@oracle.com> <20190111215506.jmp2s5end2vlzhvb@black.fi.intel.com> From: Steven Sistare Organization: Oracle Corporation Message-ID: Date: Mon, 14 Jan 2019 10:35:46 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9136 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901140127 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/11/2019 6:28 PM, Mike Kravetz wrote: > On 1/11/19 1:55 PM, Kirill A. Shutemov wrote: >> On Fri, Jan 11, 2019 at 08:10:03PM +0000, Mike Kravetz wrote: >>> At LPC last year, Boaz Harrosh asked why he had to 'jump through hoops' >>> to get an address returned by mmap() suitably aligned for THP. It seems >>> that if mmap is asking for a mapping length greater than huge page >>> size, it should align the returned address to huge page size. A better heuristic would be to return an aligned address if the length is a multiple of the huge page size. The gap (if any) between the end of the previous VMA and the start of this VMA would be filled by subsequent smaller mmap requests. The new behavior would need to become part of the mmap interface definition so apps can rely on it and omit their hoop-jumping code. Personally I would like to see a new MAP_ALIGN flag and treat the addr argument as the alignment (like Solaris), but I am told that adding flags is problematic because old kernels accept undefined flag bits from userland without complaint, so their behavior would change. - Steve >>> THP alignment has already been added for DAX, shm and tmpfs. However, >>> simple anon mappings does not take THP alignment into account. >> >> In general case, when no hint address provided, all anonymous memory >> requests have tendency to clamp into a single bigger VMA and get you >> better chance having THP, even if a single allocation is too small. >> This patch will *reduce* the effect and I guess the net result will be >> net negative. > > Ah! I forgot about combining like mappings into a single vma. Increasing > alignment could/would prevent this. > >> The patch also effectively reduces bit available for ASLR and increases >> address space fragmentation (increases number of VMA and therefore page >> fault cost). >> >> I think any change in this direction has to be way more data driven. > > Ok, I just wanted to ask the question. I've seen application code doing > the 'mmap sufficiently large area' then unmap to get desired alignment > trick. Was wondering if there was something we could do to help. > > Thanks >