Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4493489imu; Tue, 15 Jan 2019 00:37:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN59kq5iK7EYuCNN3icSm0R7QoqyAf99PjKGyO8OCOHm4ahuZW6j1EbDSxiljv2R+XdNqAxo X-Received: by 2002:a62:4d81:: with SMTP id a123mr2921318pfb.122.1547541458543; Tue, 15 Jan 2019 00:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547541458; cv=none; d=google.com; s=arc-20160816; b=BcvWZ8/buNqTgCxhxGFhfq7tAWFPU0Lcv7rGnna0mp39y5xC2WF4RRyNJieMDAFwXn QHhEX9e5sr9iuaSBPmJjrG2LTIQwr476wYI5r8ZNvP+TD4TKe0NuwFPPIOSUAlWyQUtH +HzYPUfJhyN1EECmlQ0wXViO7LLeaSQJH5hzlch3jXK/cP5sntK0gKfQ7oNN6pjZgidH WO0giYXdf2vlmrRUIdUSzi/JjLKRFz9B4VrtVqSrYsHfrm7lGAR4RlTZk1DlQHONyR/9 VfcT96dBH0LSG2obBSQFlrrc1eRlUHxOBkAHLtcitkV4BBZ/WU7x4C1RptXifWFIbQXI Lp4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=evBP+gUqkh/3ByH6MmOwERT0Raa/qT0rUXNL3TW8osc=; b=TD/07z98DZ0g46/FDIOI9jfyjYBadvVE4Xr0/FYvVPuj1vdc/nnM0/QH3lqaUR9uYQ FSGKuI1WlRNfIkg2C0JPwh1guJx/PIfqAC1Pd7RdoNSlQVqsZ7fd0xzb9C9rJFrYz3rL PwY6MqP+ze99oTHVHHT0eEegAuTcX/ZKUWZdPF6S/Sa8YXlrHrplE0lCCnbi5evM1uQ2 dSOQXf0hN5pRrAEwz2gFhNcAj6yt2MgZ3gM/ppF+xDkwlKh7ngjO0tNyo6r3AUqlDD3T 1ZlL84zu0RwqlLiqpUEQ/gPgiRw+Wz+EyKfCF7bG0SZpCTqolqyDLuWhxZIlaKl1K1my 6ehA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=GniXtc0t; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21si2654147pge.374.2019.01.15.00.37.22; Tue, 15 Jan 2019 00:37:38 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=GniXtc0t; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728547AbfAOIY5 (ORCPT + 99 others); Tue, 15 Jan 2019 03:24:57 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33330 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbfAOIY5 (ORCPT ); Tue, 15 Jan 2019 03:24:57 -0500 Received: by mail-pl1-f194.google.com with SMTP id z23so957376plo.0 for ; Tue, 15 Jan 2019 00:24:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=evBP+gUqkh/3ByH6MmOwERT0Raa/qT0rUXNL3TW8osc=; b=GniXtc0tZGzWP+BCETg+jiAaaeptD9SQyLuzkUWo/s3subYezEaUMVdXnoei4ktzqh iXtAwYXxj62oKwTXVrakmxs4ruox1+dOKDUSg0T7rGu2LacFqqv6SHL55yVyNsk04Vbd /F9yHQAyH8luvmRgHCkPvx9AtkfHdK/M8QbmW8FJLccfFen4rc4iIU1H7sFORnjYQeF9 LYng1mpmJmUlFtuK174ho0b9hpMhyxNrG//WGF1rFAl1or4KkXXYocH9YRzMqK7a6Hit yCt2vjBS5lcZlblNZC/1NHE0omSe9RIJ/0PUqhQXV+JSCMBZV7zD/zda+1FVcUcAL19g TPSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=evBP+gUqkh/3ByH6MmOwERT0Raa/qT0rUXNL3TW8osc=; b=PiNyRsSPxZw6mF9qWUWAr9ZoLd5ehVYdBh99Ze1bmpAMY584FDSgSgtqqvG6ATobW1 shh84P1tmN9m6/6XZEGcDXN+fT2Do61cq+Y0aqA5zQkD7ohvy0+eZCDyI1n+8sEpcvOq AeEID95IsLPum8tJfhO++KCpGlzdoLevCgQUY33lKGM+YKV4kbMr9ltgyqUuSzUHiAhS 68IfEKCsyu/OyeeQeUXhREFzUUCdSb6Kec2iwu1gJgscmJTsiFLXkn1+tyvar18reDf0 cgdHlUnVXSl4yW/fEnuFtPTCZTXJ4jc9AC4WIg/EE8jnpp2DZAMJ9HKpbZeJ7/nTt3GY exqQ== X-Gm-Message-State: AJcUukexSGQu6i3r98so4J2+Iqbe3wxvAEH329FbK1kwNU/U4AOqnX4p GVxWHkW3ZlYhcwUrP2mtVSvpAA== X-Received: by 2002:a17:902:5ac7:: with SMTP id g7mr2881940plm.212.1547540696183; Tue, 15 Jan 2019 00:24:56 -0800 (PST) Received: from kshutemo-mobl1.localdomain ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id m3sm3109148pgl.69.2019.01.15.00.24.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 00:24:55 -0800 (PST) Received: by kshutemo-mobl1.localdomain (Postfix, from userid 1000) id D34DA30064D; Tue, 15 Jan 2019 11:24:50 +0300 (+03) Date: Tue, 15 Jan 2019 11:24:50 +0300 From: "Kirill A. Shutemov" To: Mike Kravetz Cc: Steven Sistare , "Kirill A. Shutemov" , linux_lkml_grp@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hugh Dickins , Michal Hocko , Dan Williams , Matthew Wilcox , Toshi Kani , Boaz Harrosh , Andrew Morton Subject: Re: [RFC PATCH] mm: align anon mmap for THP Message-ID: <20190115082450.stl6vlrgbvikbwzq@kshutemo-mobl1> References: <20190111201003.19755-1-mike.kravetz@oracle.com> <20190111215506.jmp2s5end2vlzhvb@black.fi.intel.com> <50c6abdc-b906-d16a-2f8f-8647b3d129aa@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50c6abdc-b906-d16a-2f8f-8647b3d129aa@oracle.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 14, 2019 at 10:54:45AM -0800, Mike Kravetz wrote: > On 1/14/19 7:35 AM, Steven Sistare wrote: > > 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. > > Yes, the heuristic really should be 'length is a multiple of the huge page > size'. As you mention, this would still leave gaps. I need to look closer > but this may not be any worse than the trick of mapping an area with rounded > up length and then unmapping pages at the beginning. The question why is it any better. Virtual address space is generally cheap, additional VMA maybe more signficiant due to find_vma() overhead. And you don't *need* to unmap anything. Just use alinged pointer. > > When I sent this out, the thought in the back of my mind was that this doesn't > really matter unless there is some type of alignment guarantee. Otherwise, > user space code needs continue employing their code to check/force alignment. > Making matters somewhat worse is that I do not believe there is C interface to > query huge page size. I thought there was discussion about adding one, but I > can not find it. We have posix_memalign(3). -- Kirill A. Shutemov