Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp971952lqp; Fri, 22 Mar 2024 01:16:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4Esg0amj9r9k7PSOzM9d8yqzxjYpgaPlPq6XfHuxnPnvky+Hq+1h7Y84/GCHgC+ot891p8KqsqGENIF04An7MROF7Fnj3/S9ad4KA0w== X-Google-Smtp-Source: AGHT+IGxB/HI8d7w8DZjXr28Gs6ezgrLEZHxXKGJizQU+0dss3yLFcXnqTz+qwZmk9L7/P9b5Thx X-Received: by 2002:a05:6e02:f83:b0:366:27f8:bbd5 with SMTP id v3-20020a056e020f8300b0036627f8bbd5mr2070124ilo.11.1711095387252; Fri, 22 Mar 2024 01:16:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711095387; cv=pass; d=google.com; s=arc-20160816; b=XPYLx0p03mzwWfUpkWtdibwdbLWxDyVito35uMwBuD9jBMQTcrUFvCh0ha2MBArHja ugsAcdCZdlj6dpyI6dtuOyOAT3R1CL2SP0V1J9VAr9uk1Nfwq2cAGDS302FSPY/ZlSvO yh8Mg6akqF3s4ryejk7viHP0MnxyIF+dsBcUad52FnuvVak8pWieJqk4uh261s5RA+dj BA25LV0QyueYXAz4AtZkwhVaCiq0nPfS8CLgkrU6+kN2tIL3G95R8gKJcvZuwu6iSlSf UCZUjdBa+9ztXlhF6Gt9JEWcRvDIHlFtcHejQqiGlinB+b0WkQUxSKLQ4wXFqiyeixfw z8oQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=rpmxjaTCjxoIsCCXMbq2+up7JOpfzh0860bsclMJ83s=; fh=t/WD4leUpjjcCITj9STk/aS03HHIw2+z3gRF3/WdUl8=; b=xAfzfyS390hf2FqgUIlD8yuv575uKzsRMZnDgkUdAWU68VtTDuzNrYbef7c28a08Gy VptYBZXeorr9+i2x5jv6pWMhKES6OISsIR06Pe3onNuxiE+U6YuyeGDzp4XfGrzYnuxK 9/EG6yR6w8s1sapCK7wcUbqT2wV86vLG5rJqfp+W7FsYJrCvp5B/Ul3Rf4uqeHHP5b94 Iih3CiqgBbscY6yGyPemERpMHwDnRsScFz2vO96nb4/z79U2CxgVdsYmuO0uccKMX0e+ 3wb/avf/2q9LXasy4CQqyNaRjvHMixAe8ncX6HigKGn6Jm0tvkN22zFN1OJGweBiTDi7 jU3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N3imLe0Z; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-111108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111108-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q18-20020a656852000000b005dc8a203ddesi1434619pgt.744.2024.03.22.01.16.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 01:16:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N3imLe0Z; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-111108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111108-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 93B4FB23D92 for ; Fri, 22 Mar 2024 08:13:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 696BC168A4; Fri, 22 Mar 2024 08:13:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N3imLe0Z" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74F6C15AD0 for ; Fri, 22 Mar 2024 08:13:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711095190; cv=none; b=ESjSMRLJS2hYL9aLxKmn3XqvV1aMUybCDN+qZX3u4WMlSwWUZZzXojZK8kLkDuepMenvVoAE8WEl8YAlmFbNRKT+bbmFSOpyO0Fbigg8PlAPWsNfXwD5TjnQXbsKO9VSU2eupeRw6hawmm0VozrWprWkMf9A5KUkvPf2EHEHqc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711095190; c=relaxed/simple; bh=ncfiTI7ran5GaKmZX0N1CXbIpkzQPf3m7yQLpgMjchE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FpZ16f4Sq0BS/WBvrWnmwtLvcToi9ay0DJ1Vct2bC6xxhWT3B5b/XtVHy2GDrnV71O3pmcQz8DmTRCC84zkNk7yvdhec8u73oDTFlWCCqiHAH/iemr7eC/6aLC6KN65z/FxR+QkNUYGBFxyof5/iUOQi2Ox82TQ/MZPrFqiwyKI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=N3imLe0Z; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711095187; 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:autocrypt:autocrypt; bh=rpmxjaTCjxoIsCCXMbq2+up7JOpfzh0860bsclMJ83s=; b=N3imLe0ZiWRe6WALhoth2GgGl3zGxEdGpMCc5sxa5LX/Gc/cRydOI7h9bDsLqcDk+T7VeS BRYBTo4H80PCIP2LQ1rG+bHtHdRiNiqEoiDTFSGkaMGbYcNmqVRznTpPWmFqqi3NrGi254 W9lRX8TIRJNEjG7MYYhms5sGLi55bN8= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-338-rYk_1LwQNTSGMhEn1Emmmg-1; Fri, 22 Mar 2024 04:13:05 -0400 X-MC-Unique: rYk_1LwQNTSGMhEn1Emmmg-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-5158a57abd4so1639363e87.3 for ; Fri, 22 Mar 2024 01:13:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711095184; x=1711699984; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rpmxjaTCjxoIsCCXMbq2+up7JOpfzh0860bsclMJ83s=; b=a8UFCSBqa7U9yYLRS9blWrrVYfHthoaTDW54TTQN0sBdsWWoby+6tal8JJo9fwAXq1 J2HarT/8IzJ/PYhKx9PGzYTgzp6mnUAN0rn2FoQoA30lul5BqBUWt4zEEwOgKVGFCT7S lmaiWIlVybcV36ETTOTZMCdalvNS1rSzeDVOUpoaw3nDV0yNNv0y4aYpwq/x8bNapo+y fdXHCpB09c14iRYdBWZqNEyHCHJSBUNfw6najAjt7RtpoD81X3Fb5iIG3xnGpKpzCgxm LeaSJ7z7h+2l6CZxmoKR0mDxW6hOkFkmvXPw5FmkcSUoDiPXu4pHyNO+/2V/T3cfL/T5 fllw== X-Gm-Message-State: AOJu0Yy6hfhJ+R2MkDjui/I9fdcSJtRR1q2QvmVtLKagD72t0xrLSyHY mgkNI+edn+gQ2QSCGCL2IGIc4BDcSZ7CAuExOEvaSIoiyb77delJ5fT0d9Xq36TPXSDkk0jFNFh rz3VoiKYhO1FMV05xtTkcvV5tklzEpibZuoNNX5cbg57y4S3ixISGqLhNpuoLkQ== X-Received: by 2002:a19:e015:0:b0:513:30fb:d64 with SMTP id x21-20020a19e015000000b0051330fb0d64mr1053482lfg.44.1711095184193; Fri, 22 Mar 2024 01:13:04 -0700 (PDT) X-Received: by 2002:a19:e015:0:b0:513:30fb:d64 with SMTP id x21-20020a19e015000000b0051330fb0d64mr1053456lfg.44.1711095183583; Fri, 22 Mar 2024 01:13:03 -0700 (PDT) Received: from [192.168.3.108] (p5b0c6e7f.dip0.t-ipconnect.de. [91.12.110.127]) by smtp.gmail.com with ESMTPSA id dn1-20020a0560000c0100b0033ec7182673sm1481745wrb.52.2024.03.22.01.13.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Mar 2024 01:13:03 -0700 (PDT) Message-ID: <17c1f86e-e6bf-4be0-88cd-c4afecb02310@redhat.com> Date: Fri, 22 Mar 2024 09:13:02 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/2] mm/userfaultfd: don't place zeropages when zeropages are disallowed To: Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Andrew Morton , Alexander Gordeev , Sven Schnelle , Gerald Schaefer , Andrea Arcangeli , kvm@vger.kernel.org, linux-s390@vger.kernel.org References: <20240321215954.177730-1-david@redhat.com> <20240321215954.177730-2-david@redhat.com> <48d1282c-e4db-4b55-ab3f-3344af2440c4@redhat.com> Content-Language: en-US From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8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9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 21.03.24 23:46, Peter Xu wrote: > On Thu, Mar 21, 2024 at 11:29:45PM +0100, David Hildenbrand wrote: >> On 21.03.24 23:20, Peter Xu wrote: >>> On Thu, Mar 21, 2024 at 10:59:53PM +0100, David Hildenbrand wrote: >>>> s390x must disable shared zeropages for processes running VMs, because >>>> the VMs could end up making use of "storage keys" or protected >>>> virtualization, which are incompatible with shared zeropages. >>>> >>>> Yet, with userfaultfd it is possible to insert shared zeropages into >>>> such processes. Let's fallback to simply allocating a fresh zeroed >>>> anonymous folio and insert that instead. >>>> >>>> mm_forbids_zeropage() was introduced in commit 593befa6ab74 ("mm: introduce >>>> mm_forbids_zeropage function"), briefly before userfaultfd went >>>> upstream. >>>> >>>> Note that we don't want to fail the UFFDIO_ZEROPAGE request like we do >>>> for hugetlb, it would be rather unexpected. Further, we also >>>> cannot really indicated "not supported" to user space ahead of time: it >>>> could be that the MM disallows zeropages after userfaultfd was already >>>> registered. >>>> >>>> Fixes: c1a4de99fada ("userfaultfd: mcopy_atomic|mfill_zeropage: UFFDIO_COPY|UFFDIO_ZEROPAGE preparation") >>>> Signed-off-by: David Hildenbrand >>> >>> Reviewed-by: Peter Xu >>> >>> Still, a few comments below. >>> >>>> --- >>>> mm/userfaultfd.c | 35 +++++++++++++++++++++++++++++++++++ >>>> 1 file changed, 35 insertions(+) >>>> >>>> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c >>>> index 712160cd41eca..1d1061ccd1dea 100644 >>>> --- a/mm/userfaultfd.c >>>> +++ b/mm/userfaultfd.c >>>> @@ -316,6 +316,38 @@ static int mfill_atomic_pte_copy(pmd_t *dst_pmd, >>>> goto out; >>>> } >>>> +static int mfill_atomic_pte_zeroed_folio(pmd_t *dst_pmd, >>>> + struct vm_area_struct *dst_vma, unsigned long dst_addr) >>>> +{ >>>> + struct folio *folio; >>>> + int ret; >>> >>> nitpick: we can set -ENOMEM here, then >>> >>>> + >>>> + folio = vma_alloc_zeroed_movable_folio(dst_vma, dst_addr); >>>> + if (!folio) >>>> + return -ENOMEM; >>> >>> return ret; >>> >>>> + >>>> + ret = -ENOMEM; >>> >>> drop. >> >> Sure! >> >>> >>>> + if (mem_cgroup_charge(folio, dst_vma->vm_mm, GFP_KERNEL)) >>>> + goto out_put; >>>> + >>>> + /* >>>> + * The memory barrier inside __folio_mark_uptodate makes sure that >>>> + * preceding stores to the page contents become visible before >>>> + * the set_pte_at() write. >>>> + */ >>> >>> This comment doesn't apply. We can drop it. >>> >> >> I thought the same until I spotted that comment (where uffd originally >> copied this from I strongly assume) in do_anonymous_page(). >> >> "Preceding stores" here are: zeroing out the memory. > > Ah.. that's okay then. > > Considering that userfault used to be pretty cautious on such ordering, as > its specialty to involve many user updates on the page, would you mind we > mention those details out? > > /* > * __folio_mark_uptodate contains the memory barrier to make sure > * the page updates to the zero page will be visible before > * installing the pgtable entries. See do_anonymous_page(). > */ > > Or anything better than my wordings. Sure, I'd slightly reword it. The following on top: diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 1d1061ccd1dea..9d385696fb891 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -320,20 +320,19 @@ static int mfill_atomic_pte_zeroed_folio(pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr) { struct folio *folio; - int ret; + int ret = -ENOMEM; folio = vma_alloc_zeroed_movable_folio(dst_vma, dst_addr); if (!folio) - return -ENOMEM; + return ret; - ret = -ENOMEM; if (mem_cgroup_charge(folio, dst_vma->vm_mm, GFP_KERNEL)) goto out_put; /* * The memory barrier inside __folio_mark_uptodate makes sure that - * preceding stores to the page contents become visible before - * the set_pte_at() write. + * zeroing out the folio become visible before mapping the page + * using set_pte_at(). See do_anonymous_page(). */ __folio_mark_uptodate(folio); Thanks! -- Cheers, David / dhildenb