Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4171398ybg; Tue, 29 Oct 2019 03:16:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyp5F2dkHo9CHgzhzgBWZ+R67kTRgAvF6PQnUjzmyxjsrZYF+xQUyCAOQ9mH1n1m4OeKlSV X-Received: by 2002:a17:906:2584:: with SMTP id m4mr2424689ejb.287.1572344169828; Tue, 29 Oct 2019 03:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572344169; cv=none; d=google.com; s=arc-20160816; b=Lm4KIcPLyRRmzFVnVRxsCas5cG5XQ6AFofIShSVvcuK+R/mrH2I24oql0aDvO/8CGY Ksh+6ZsorR99TGZPEN1WNTjbEOQhKFTHr8k8W802e+p2dJGBYSGNTrWTE8+OZUGZvuSM 6WZiF504V/Ng4t4w8z0UzFhyCcrRFOE5+en3Ysi9tMUor+lpYp1x1Nuv8Dz1WtHt7Vhb p+DzMXsU5pyHYp4OP68lGqXS0d9M866ua0MnOX2lOuDxHrJy+VFrKpybd55QVO6+XDdt C7T5ZIoxPJ3ikxaqa1AokEZaxRDu9JOmZfg3SxgA4O3JNKk+UtrGhxlBNdkjZa2edfeN +Z0Q== 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=+n+RP1mR3xEilvEN1+IRwIixpxzsawJ+q/HX82e54Js=; b=eAZDHMFAPGiIlsTfO/yu7QAsjh3PkBlB95kCy4SVoER5kkHgzO0Zj+hwNHjyUTgVuV Qmeh2WWIXpLQmUV6MoAgzIJPkTrD30o57H/ku9eO5Gt98gStEWJgbanKnIMzk3ooutSO P/3X4UBsWecf3DLka7X0qXIb+VPtW13x9tAzgQF2dWzby/3GHttvAV+OSmir9yHyq1Vk nqX5KlyU4Xundn9dbJbT+RSmR+Qmh/84XihHi1C+aX4xU5AruGDO9TWji64Z5koonalw EwSewZirdJSpIXcYdHxnMixCwwAanG1ce4WhP2162M4fm5MusqbX4j4spSf4PE2OZjo3 kZUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bK6YBI1j; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s40si3334606edd.233.2019.10.29.03.15.46; Tue, 29 Oct 2019 03:16:09 -0700 (PDT) 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=@kernel.org header.s=default header.b=bK6YBI1j; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730195AbfJ2I4D (ORCPT + 99 others); Tue, 29 Oct 2019 04:56:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:48642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729695AbfJ2I4C (ORCPT ); Tue, 29 Oct 2019 04:56:02 -0400 Received: from rapoport-lnx (190.228.71.37.rev.sfr.net [37.71.228.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1031420663; Tue, 29 Oct 2019 08:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572339362; bh=RCMUTEieUAqbdDi3UXC44oJQHvnrbU2QZQPBK7vKBHo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bK6YBI1jHf1yer+gIAFBkdQfdkJZfxdS24Gvl3LhKuDLpEa8DWiPe8Sr+QPDFcRYj 4XIAV2Tn4t1Puqkg2rtTqMX+AKf6wJ6qNHzPTy7COE4QD0QxiWPoIiygzCaMPZVLSN 5WIqGWIJMAxMy0jB5tFSVt1yZ4+rFA618tmvoMTI= Date: Tue, 29 Oct 2019 09:55:53 +0100 From: Mike Rapoport To: Christopher Lameter Cc: "Kirill A. Shutemov" , linux-kernel@vger.kernel.org, Alexey Dobriyan , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Dave Hansen , James Bottomley , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-api@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, Mike Rapoport Subject: Re: [PATCH RFC] mm: add MAP_EXCLUSIVE to create exclusive user mappings Message-ID: <20191029085551.GA18773@rapoport-lnx> References: <1572171452-7958-1-git-send-email-rppt@kernel.org> <1572171452-7958-2-git-send-email-rppt@kernel.org> <20191028123124.ogkk5ogjlamvwc2s@box> <20191028130018.GA7192@rapoport-lnx> <20191028131623.zwuwguhm4v4s5imh@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 29, 2019 at 07:08:42AM +0000, Christopher Lameter wrote: > On Mon, 28 Oct 2019, Kirill A. Shutemov wrote: > > > Setting a single 4k page non-present in the direct mapping will require > > splitting 2M or 1G page we usually map direct mapping with. And it's one > > way road. We don't have any mechanism to map the memory with huge page > > again after the application has freed the page. > > > > It might be okay if all these pages cluster together, but I don't think we > > have a way to achieve it easily. > > Set aside a special physical memory range for this and migrate the > page to that physical memory range when MAP_EXCLUSIVE is specified? I've talked with Thomas yesterday and he suggested something similar: When the MAP_EXCLUSIVE request comes for the first time, we allocate a huge page for it and then use this page as a pool of 4K pages for subsequent requests. Once this huge page is full we allocate a new one and append it to the pool. When all the 4K pages that comprise the huge page are freed the huge page is collapsed. And then on top of this we can look into compaction of the direct map. Of course, this would work if the easy way of collapsing direct map pages Kirill mentioned on other mail will work. > Maybe some processors also have hardware ranges that offer additional > protection for stuff like that? > -- Sincerely yours, Mike.