Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4623045pxk; Wed, 30 Sep 2020 07:42:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOrc9D5yhY2x0lkWgvbBz2Zu7wB6Yxl5cSWRY96Gx7rj4Gp7eh/fPH5Us6vr+1N9emMv2T X-Received: by 2002:a17:906:915:: with SMTP id i21mr3077617ejd.113.1601476945903; Wed, 30 Sep 2020 07:42:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601476945; cv=none; d=google.com; s=arc-20160816; b=i9YXI507Fx7AISXlKAGIM/bMIMRuoKqDcO0PXdFuEOGhU24bVCpM2gYbi1YHux85c2 0PCRbwbgLQdCXaOdDB1UDH9gzD+E6GPHRG5ISd9Mhp0WPe70HB4PuuprdTmCNU6gbvYC ZuUQw4TDGk3LNQibRvRB02EjXrXNHruYCM8Q3uhVLG2+UfMhcGsZPJaMOTqmmrKKn/2H f2KXnNSvH5uvNnfEO6hsQ5cnJtKxIPyvCbIrDV7T5MKhQgayDKoFt8/Ltnw4gwKne0XF 2sAUCFkR73xEZ1pgZauvzF85QlUtODM5/RR34YScxZEA+wbGfBndvUP/xur0htzSm+0n 9aBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:reply-to:from:subject :message-id:dkim-signature; bh=TOhFRkH6eBrNvZOnRv3vltvV9RWcAvaYO4zGgzF6rYA=; b=0AV7z7Dwr+mtghlhWpeUuN+e5X2R9akp6Yb4xbuRx9jwCecY9QQ3l618V4fH7P4pbQ U+0X9q6CN6LNaf02vvkHw+jnssFuZJLwPfl/YixF9gF28rGPtygZXQN9TFOnWv19+buE VV6CmA5ZxLy5OB3s3vMquYB/g/6wr8IQJkh5pQzCwJpfGMeEahaZrBY9xvWVOCzN5nWk mtWDLu4GuOyx38p/5xGIka2os2LjbDnZrjQfHacZeaVNbyxyewWBdJg1HmhQgmzH+Xsj hyTLEjFl5Jqv4C4fx/A0lD73y59D9P8jfL+EBUpWFqw9aoI5CgdDiqbF1Gmee+k37QjG WqKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=V6DwgTAK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f26si1355378ejc.612.2020.09.30.07.42.02; Wed, 30 Sep 2020 07:42:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=V6DwgTAK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730539AbgI3Okx (ORCPT + 99 others); Wed, 30 Sep 2020 10:40:53 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:7438 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728149AbgI3Okw (ORCPT ); Wed, 30 Sep 2020 10:40:52 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08UEXn0h002260; Wed, 30 Sep 2020 10:40:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : reply-to : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=TOhFRkH6eBrNvZOnRv3vltvV9RWcAvaYO4zGgzF6rYA=; b=V6DwgTAKxpxWbmkbUs+va5rzIxR+lCshyKHzDJTztxt1Hk13G4unr60eZMYIJnN4V2nq /jEkjdRudg7CAzTYrBENRqt8sHleTLsYAiL8SdB1aCk1NfjtQWhrSGCd4WgBzHKX3W+/ htaiTmMRRzk9Izsiz8TbNboGeepzjBW1wDZ4Rm4UDs6BeYGHkgijKGyl5/2Vc9dKgt5M joTxP4/HYR3U/jMJFF9VaYNuGVLX0x0CLFiJX90UgMw/ZTYxe7OSJhgvoG0dEbOCj/Uo JMtTSmu1uVj0Nyo/Cew9CAVzfjzQgDiHlHMhc76YsmWCR9xbt08JW2T2lE9OscEE5eMz hw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33vtprt807-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Sep 2020 10:40:14 -0400 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08UEY9wX003413; Wed, 30 Sep 2020 10:40:09 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 33vtprt7wm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Sep 2020 10:40:08 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08UEcK6A011409; Wed, 30 Sep 2020 14:40:03 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma05wdc.us.ibm.com with ESMTP id 33sw99e3uh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Sep 2020 14:40:03 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08UEdweH34472466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Sep 2020 14:39:58 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45B5D78072; Wed, 30 Sep 2020 14:40:02 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FEF578060; Wed, 30 Sep 2020 14:39:56 +0000 (GMT) Received: from jarvis (unknown [9.85.129.253]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 30 Sep 2020 14:39:55 +0000 (GMT) Message-ID: <371c27d97067654171e5c1019340b56cffadae7a.camel@linux.ibm.com> Subject: Re: [PATCH v6 5/6] mm: secretmem: use PMD-size pages to amortize direct map fragmentation From: James Bottomley Reply-To: jejb@linux.ibm.com To: Mike Rapoport , Peter Zijlstra Cc: Mike Rapoport , Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , David Hildenbrand , Elena Reshetova , "H. Peter Anvin" , Idan Yaniv , Ingo Molnar , "Kirill A. Shutemov" , Matthew Wilcox , Mark Rutland , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Shuah Khan , Tycho Andersen , Will Deacon , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-riscv@lists.infradead.org, x86@kernel.org Date: Wed, 30 Sep 2020 07:39:54 -0700 In-Reply-To: <20200930102745.GC3226834@linux.ibm.com> References: <20200924132904.1391-1-rppt@kernel.org> <20200924132904.1391-6-rppt@kernel.org> <20200925074125.GQ2628@hirez.programming.kicks-ass.net> <20200929130529.GE2142832@kernel.org> <20200929141216.GO2628@hirez.programming.kicks-ass.net> <20200929145813.GA3226834@linux.ibm.com> <20200929151552.GS2628@hirez.programming.kicks-ass.net> <20200930102745.GC3226834@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-30_07:2020-09-30,2020-09-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxlogscore=690 spamscore=0 clxscore=1015 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009300112 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-09-30 at 13:27 +0300, Mike Rapoport wrote: > On Tue, Sep 29, 2020 at 05:15:52PM +0200, Peter Zijlstra wrote: > > On Tue, Sep 29, 2020 at 05:58:13PM +0300, Mike Rapoport wrote: > > > On Tue, Sep 29, 2020 at 04:12:16PM +0200, Peter Zijlstra wrote: > > > > It will drop them down to 4k pages. Given enough inodes, and > > > > allocating only a single sekrit page per pmd, we'll shatter the > > > > directmap into 4k. > > > > > > Why? Secretmem allocates PMD-size page per inode and uses it as a > > > pool of 4K pages for that inode. This way it ensures that > > > __kernel_map_pages() is always called on PMD boundaries. > > > > Oh, you unmap the 2m page upfront? I read it like you did the unmap > > at the sekrit page alloc, not the pool alloc side of things. > > > > Then yes, but then you're wasting gobs of memory. Basically you can > > pin 2M per inode while only accounting a single page. > > Right, quite like THP :) > > I considered using a global pool of 2M pages for secretmem and > handing 4K pages to each inode from that global pool. But I've > decided to waste memory in favor of simplicity. I can also add that the user space consumer of this we wrote does its user pool allocation at a 2M granularity, so nothing is actually wasted. https://git.kernel.org/pub/scm/linux/kernel/git/jejb/secret-memory-preloader.git/ James