Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp619807pxj; Fri, 14 May 2021 11:16:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl/QEe1Lk6FKU9/MesncYyKE7nAOuiSU3vax1vVICXqg/u7yJcQnivaDqI/eWD09vX86wI X-Received: by 2002:a05:6402:1a:: with SMTP id d26mr58093203edu.99.1621016191076; Fri, 14 May 2021 11:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621016191; cv=none; d=google.com; s=arc-20160816; b=wqHHwu/gJTmRnzcDtpouOhdukyJr0Hm5N9Ot18Y1+5HHGRygbhx+ej9B3BUohJXout aCu4iOf5q/ws4uPwtvY9zn+QW6yPAlBurr/T+9zi1O9DU6GXjvA89/I6Ikg4vD/QIBLg B2DBReb//Dd/j9BD66tRU/JA/zc/LFbtVp4rbElPmR7i4MdzouDzj9juueaCgHdXFZ9Q 14sGCoA4PMRWk8v4jdYmq21Z17x0zUq9aPFOg8MSQCcr4bhBpYdLnr6xgryaK0ja6m8l MBEkDfoOhBuMdb+3Dm6ssX6HBFuTPTplSmd6Bnj90+S+k9027oj48n8R9SKb04601Bju n5BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0wcDpE/Q+m1DFHQZr7axynmSMqacQ9s1VDrFV+vCPSw=; b=OhAPh3sObZTmZ7QEzacbILc3hTeMe+S+eWElPoUEgXLmSF8FB/Ibwx7dpyugsUFn4Z fMWNNbo+mpzMXAqKGOwg1hVtAGJXxKvMcFSjBuGk5J9NfSQfrZZPtgH4hidFSfHvZbVV DLsbO80ZImknHKsn1ZB5LcERTU+VejoehCamDG6cF8JiJOoCElavnODCrCUrYNjIhDkW 6a0xiasWnh6AMnaD+nQcPXrghEXPO8c3HMXAESI0Tso8uzC6h4q/UklMD5o5uarP4z0T y7D85l21nXgsTnygSDoTWa4iZWQpLTSIUqx+gcVhPo1ws3vdggzws5ZhdA4LKAX1k6OQ ggzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIznZmZ3; 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 e16si6541040ejj.154.2021.05.14.11.16.07; Fri, 14 May 2021 11:16:31 -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=@redhat.com header.s=mimecast20190719 header.b=jIznZmZ3; 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 S232977AbhENMc3 (ORCPT + 99 others); Fri, 14 May 2021 08:32:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21612 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233446AbhENMcY (ORCPT ); Fri, 14 May 2021 08:32:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620995473; 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: in-reply-to:in-reply-to:references:references; bh=0wcDpE/Q+m1DFHQZr7axynmSMqacQ9s1VDrFV+vCPSw=; b=jIznZmZ3EOlhmOrWjLQzDMRfhw6NlAqwAhoxyVUqgN0nk+BQfIC1gDSjdXW+ACg6EddNaM fYkpY4KtNVQFDzQDeSVF+BBk8wlM5thbGBT5t7AyNq1ssN7H+ljIKPxICm9VByKbN/Aoin vXOhvQMtPSut/6mPidrrkjcERZk//wI= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-560-RLiJ6h0xPMWD24XduIprzQ-1; Fri, 14 May 2021 08:31:11 -0400 X-MC-Unique: RLiJ6h0xPMWD24XduIprzQ-1 Received: by mail-qk1-f198.google.com with SMTP id v1-20020a05620a1221b02902ea88445e01so18571083qkj.9 for ; Fri, 14 May 2021 05:31:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0wcDpE/Q+m1DFHQZr7axynmSMqacQ9s1VDrFV+vCPSw=; b=mHGvMdZv9yeN9hNy0tbl4h9Qv110S9uTJboXvn5v3dRGS9HoF3JDESK73ZegE3Bp3M mb2yoSd+jjezyG1Mu9NXukUbspk5vmVbn1Z0spWk4Lz1KyVEB/dfWQRm7kxMnJ/gE0rF /A0BaIP33fjW9BSMJds5U1pmeUFikvvC1+95vE+oUXIUxmHDoIyvAwCwRivHFhPnYVyK w5y41e9/hWTzv/M3htpUZTFE1B/m92NQef4J5UPkTiCNv2J/HryB9yyAd+gBZv/zJdVi GtmgkmlEZeLf0Jg0dDysQAUCXEE6M+875eZwLJWrmNwl1wfXnQv8dhn52zvxII4QwKzd RZuQ== X-Gm-Message-State: AOAM533x4XvUL5dMqvFdZRLcFnwJC8bdN9dw6E3yVgwi7B+4nkXnznby 4uhz5DaY6xK6iely0GzUClxuPCcPz4CA3r9mDX0p0aiTWPEBiGwVfvy3gcQ2LJyc6b3rBY4VLgB hMJ7ZWoY6E2zxso8wdCANvru3 X-Received: by 2002:a37:f512:: with SMTP id l18mr42878514qkk.89.1620995470943; Fri, 14 May 2021 05:31:10 -0700 (PDT) X-Received: by 2002:a37:f512:: with SMTP id l18mr42878477qkk.89.1620995470612; Fri, 14 May 2021 05:31:10 -0700 (PDT) Received: from t490s (bras-base-toroon474qw-grc-72-184-145-4-219.dsl.bell.ca. [184.145.4.219]) by smtp.gmail.com with ESMTPSA id n15sm4462637qti.51.2021.05.14.05.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 May 2021 05:31:10 -0700 (PDT) Date: Fri, 14 May 2021 08:31:09 -0400 From: Peter Xu To: Mike Kravetz Cc: Mina Almasry , Axel Rasmussen , Linux-MM , Andrew Morton , open list Subject: Re: [PATCH] mm, hugetlb: fix resv_huge_pages underflow on UFFDIO_COPY Message-ID: References: <20210513234309.366727-1-almasrymina@google.com> <09dc0712-48e8-8ba2-f170-4c2febcfff83@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Mike, On Thu, May 13, 2021 at 09:02:15PM -0700, Mike Kravetz wrote: [...] > I am also concerned with the semantics of this approach and what happens > when a fault races with the userfaultfd copy. Previously I asked Peter > if we could/should use a page found in the cache for the copy. His > answer was as follows: > > AFAICT that's the expected behavior, and it need to be like that so as to avoid > silent data corruption (if the page cache existed, it means the page is not > "missing" at all, then it does not suite for a UFFDIO_COPY as it's only used > for uffd page missing case). I didn't follow the rest discussion in depth yet... but just to mention that the above answer was for the question whether we can "update the page in the page cache", rather than "use a page found in the page cache". I think reuse the page should be fine, however it'll definitely break existing user interface (as it'll expect -EEXIST for now - we have kselftest covers that), meanwhile I don't see why the -EEXIST bothers a lot: it still tells the user that this page was filled in already. Normally it was filled in by another UFFDIO_COPY (as we could have multiple uffd service threads) along with a valid pte, then this userspace thread can simply skip this message as it means the event has been handled by some other servicing thread. (This also reminded me that there won't be a chance of UFFDIO_COPY race on page no page fault at least, since no page fault will always go into the uffd missing handling rather than filling in the page cache for a VM_UFFD_MISSING vma; while mmap read lock should guarantee VM_UFFD_MISSING be persistent) Thanks, -- Peter Xu