Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3477784pxx; Mon, 2 Nov 2020 09:54:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJySMWiuVTl2VBGId8tBxJpGdNcf+o4dC/EaKbCXxzfJziciyAD13xGK9grER+FyU4mSHvuZ X-Received: by 2002:a50:b584:: with SMTP id a4mr17875792ede.301.1604339655058; Mon, 02 Nov 2020 09:54:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604339655; cv=none; d=google.com; s=arc-20160816; b=WxYnv5UhWeL3ogIyKIm/lrY14sUjPKV6l0gq7TYkVq+WEYEVKcxg8NuyHwDcsKVRhH 79/qEf9eUnZtRHmVhG1pPl1jSHI6cRjC8aLYlmFVF4HHhoD43mrj70QJlSllC3rY3WUc QNK6wNevD+AfKlX7xAiHQLyCHFXQj6RtGFMVnRLWQmZ3aqCDA+oR3uXVYMz4lRhABiVJ jnkg9hXb/wlbLt9Mr2VotRDQHdTEam0n29pFAWqLVe/RZiQMHiTxLQguNV7e59zpKbmu +0oxzaBrcjS9jOnJJPU7F3ewkmuk0qjnj2lxu26QklCvydJsz/3ZE30cATZ9LMyHnCKZ uegg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=lp/prYQuMgVXccCGCiV61cLz4v5q5/mm6tHCPraHIqM=; b=LUM2N6a1nj9iof8y+VFo8ol9n3Vm+NlhS1pGJn1So+5A5t/gEgRYyTzHrtZpavtpUg KJhSbkqkE5eyiqvBshAqsEzvGdK0jMWt7GkQrq78rhM9PPQX+UpvAT/q1k7z/As2pOeM AAngaSEeoDDHltjDmKWlQ88uaN/G8IowerUs5zPM0wxTX5+GzfRBWYSQaQx0w8LqejA/ lMgHUaWFJ6uoyj2jcG+D4UmPYHvAzDuNDq25TtSkjsSS0i2h1okKoVtl2SGQ5IDgrlIF IrS04RLdLEYuqx/rXAJ5HRGicQXimZEOwzLngIu+vyh7QPz2V6LYcdCh944GUJTKyJ5q 1E2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EKQezKoE; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u14si3681645edq.494.2020.11.02.09.53.50; Mon, 02 Nov 2020 09:54:15 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=EKQezKoE; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725977AbgKBRv2 (ORCPT + 99 others); Mon, 2 Nov 2020 12:51:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23314 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725848AbgKBRv1 (ORCPT ); Mon, 2 Nov 2020 12:51:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604339486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lp/prYQuMgVXccCGCiV61cLz4v5q5/mm6tHCPraHIqM=; b=EKQezKoEaQPVX0E/k1X4C/PLH+ukdpxJSN79mCzwzIu+B7Qv7oLCnGtx9+Sip+GlK1bsQJ CAf2b8g9yEqtQduC91gEuPv8Nzmr3RHL6XE2kbyRYhxXK+84na4K4NZJcF9DdLXj5yAeEV oA7Qf/09Hr525GSyHeWOYiePRs9Ql0w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-593-JugxVAtvMxar3jfSZTXWbg-1; Mon, 02 Nov 2020 12:51:22 -0500 X-MC-Unique: JugxVAtvMxar3jfSZTXWbg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1873F879512; Mon, 2 Nov 2020 17:51:18 +0000 (UTC) Received: from [10.36.113.163] (ovpn-113-163.ams2.redhat.com [10.36.113.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA9C15B4A9; Mon, 2 Nov 2020 17:51:10 +0000 (UTC) Subject: Re: [PATCH v6 0/6] mm: introduce memfd_secret system call to create "secret" memory areas To: Mike Rapoport Cc: Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , Elena Reshetova , "H. Peter Anvin" , Idan Yaniv , Ingo Molnar , James Bottomley , "Kirill A. Shutemov" , Matthew Wilcox , Mark Rutland , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , 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 References: <20200924132904.1391-1-rppt@kernel.org> <9c38ac3b-c677-6a87-ce82-ec53b69eaf71@redhat.com> <20201102174308.GF4879@kernel.org> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Mon, 2 Nov 2020 18:51:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20201102174308.GF4879@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> Assume you have a system with quite some ZONE_MOVABLE memory (esp. in >> virtualized environments), eating up a significant amount of !ZONE_MOVABLE >> memory dynamically at runtime can lead to non-obvious issues. It looks like >> you have plenty of free memory, but the kernel might still OOM when trying >> to do kernel allocations e.g., for pagetables. With CMA we at least know >> what we're dealing with - it behaves like ZONE_MOVABLE except for the owner >> that can place unmovable pages there. We can use it to compute statically >> the amount of ZONE_MOVABLE memory we can have in the system without doing >> harm to the system. > > Why would you say that secretmem allocates from !ZONE_MOVABLE? > If we put boot time reservations aside, the memory allocation for > secretmem follows the same rules as the memory allocations for any file > descriptor. That means we allocate memory with GFP_HIGHUSER_MOVABLE. Oh, okay - I missed that! I had the impression that pages are unmovable and allocating from ZONE_MOVABLE would be a violation of that? > After the allocation the memory indeed becomes unmovable but it's not > like we are eating memory from other zones here. ... and here you have your problem. That's a no-no. We only allow it in very special cases where it can't be avoided - e.g., vfio having to pin guest memory when passing through memory to VMs. Hotplug memory, online it to ZONE_MOVABLE. Allocate secretmem. Try to unplug the memory again -> endless loop in offline_pages(). Or have a CMA area that gets used with GFP_HIGHUSER_MOVABLE. Allocate secretmem. The owner of the area tries to allocate memory - always fails. Purpose of CMA destroyed. > >> Ideally, we would want to support page migration/compaction and allow for >> allocation from ZONE_MOVABLE as well. Would involve temporarily mapping, >> copying, unmapping. Sounds feasible, but not sure which roadblocks we would >> find on the way. > > We can support migration/compaction with temporary mapping. The first > roadblock I've hit there was that migration allocates 4K destination > page and if we use it in secret map we are back to scrambling the direct > map into 4K pieces. It still sounds feasible but not as trivial :) That sounds like the proper way for me to do it then. > > But again, there is nothing in the current form of secretmem that > prevents allocation from ZONE_MOVABLE. Oh, there is something: That the pages are not movable. -- Thanks, David / dhildenb