Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3768519imu; Mon, 14 Jan 2019 08:42:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN7F+u8GpcesV3Ais5DlXSPwSxeupWzQAmNDwTYYRjTgelCMwkTH142Svsz1lN4iet8IYaM3 X-Received: by 2002:a62:68c5:: with SMTP id d188mr27009663pfc.194.1547484143622; Mon, 14 Jan 2019 08:42:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547484143; cv=none; d=google.com; s=arc-20160816; b=AIVLjL5iL6qPKyA6mUQ/1Dz0wa+OhFsN0LoVbzFmo7caFwDg0igAgexRrb3sN56F4o N75weMsUlZKSdKrF3Tfqy3E0xB9mnOBH5ro3xRTMt5Pe+Zj/Lum3CoWs4jQxNPMUeC1+ sUDlQoMFiZXn7nB62xGEW6SqUrIoAhV8VQP5qhoM+JM/kZZKd8sbQLOB3rxXAGrVa2BC f9hD06x8gr4IVp+zZpTQ37FIt1jPd7V8B8EKdVcl7dngYkhmeAPuAZqU8ERkiA8giwRD wuRmNGW914aGEJhu6mVcOZ3aNr2jgNHjWjKr4hO5cihBgQWYKadzS7YRgHnyMN+0+I9D /aAw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=WlIRRnfl6YVDVj7LXZ9qWDCXZhOkV73e0c1oDA32C6U=; b=Juubn/LMwaXSpCRu4P/Ghpv6tb50wf/0JexMe4ZOaRdR17HgTeU7sfJdGhwuk423g8 Np3YlSjgJNzhWADEfh1PGYJFCkXPZ2nMqbFCQsOr4ZwwZEU8CZ5xE+rk+wB3mwJ0pIBV Dqr9foGuVfCy2EffnalQxL/1u+bje9e2IQZzOxLYpqhs0b+ctqEeDMc5YGcJmchrkqEp BORi6054xY0BhmDesWSHrJVj//YbFvTlPz4qKXT1xaYd++h/39ydXgXZ3K+eJjh0e9Xr IkUkCe5ddHuETyVw01jkP1QV6E7vJqjb7cOulrbPIrCCHmUUMEOYY7s8lTjtLvwq5jiR O7ng== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i64si645605pge.361.2019.01.14.08.42.05; Mon, 14 Jan 2019 08:42:23 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726765AbfANQkJ (ORCPT + 99 others); Mon, 14 Jan 2019 11:40:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:52892 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726656AbfANQkI (ORCPT ); Mon, 14 Jan 2019 11:40:08 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 52FDEADD2; Mon, 14 Jan 2019 16:40:07 +0000 (UTC) Date: Mon, 14 Jan 2019 17:40:04 +0100 From: Michal Hocko To: "Harrosh, Boaz" Cc: "Kirill A. Shutemov" , Mike Kravetz , "Kirill A. Shutemov" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Hugh Dickins , Dan Williams , Matthew Wilcox , Toshi Kani , Andrew Morton Subject: Re: [RFC PATCH] mm: align anon mmap for THP Message-ID: <20190114164004.GL21345@dhcp22.suse.cz> References: <20190111201003.19755-1-mike.kravetz@oracle.com> <20190111215506.jmp2s5end2vlzhvb@black.fi.intel.com> <20190114135001.w2wpql53zitellus@kshutemo-mobl1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 14-01-19 16:29:29, Harrosh, Boaz wrote: > Kirill A. Shutemov wrote: > > On Fri, Jan 11, 2019 at 03:28:37PM -0800, Mike Kravetz wrote: > >> 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. > > > > Application may want to get aligned allocation for different reasons. > > It should be okay for userspace to ask for size + (alignment - PAGE_SIZE) > > and then round up the address to get the alignment. We basically do the > > same on kernel side. > > > > This is what we do and will need to keep doing for old Kernels. > But it is a pity that those holes can not be reused for small maps, and most important > that we cannot have "mapping holes" around the mapping that catch memory > overruns What does prevent you from mapping a larger area and MAP_FIXED, PROT_NONE over it to get the protection? > > For THP, I believe, kernel already does The Right Thing™ for most users. > > User still may want to get speific range as THP (to avoid false sharing or > > something). > > I'm an OK Kernel programmer. But I was not able to create a HugePage mapping > against /dev/shm/ in a reliable way. I think it only worked on Fedora 28/29 > but not on any other distro/version. (MMAP_HUGE) Are you mixing hugetlb rather than THP? > We run with our own compiled Kernel on various distros, THP is configured > in but mmap against /dev/shm/ never gives me Huge pages. Does it only > work with unanimous mmap ? (I think it is mount dependent which is not > in the application control) If you are talking about THP then you have to enable huge pages for the mapping AFAIR. -- Michal Hocko SUSE Labs