Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4496817rdb; Fri, 15 Sep 2023 04:16:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGi4uDLA/Tj1wUlBR2AzUUXAttmyeIspcX1Zdl8gMlJ/wy74u5Cy10DmX2xnV2RK8fzq+CB X-Received: by 2002:a05:6358:721:b0:13a:6cb:4d91 with SMTP id e33-20020a056358072100b0013a06cb4d91mr1655338rwj.7.1694776568267; Fri, 15 Sep 2023 04:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694776568; cv=none; d=google.com; s=arc-20160816; b=l9rYGozKEUaclxtJQogrc1MKTcaTDrndsLorkaRgpXzCTykFYulCS6m+Hvrq/JIiNV 8N0DMaCn9DMvsw0Cz3C7Cuua5uHs8Ol8ZLGJvOGPLBx8NGU4MSlz+j9MB7M8qBT4nJeR BXn83zaABR2uc1GZgx3i2pfQNEfV8Xwpx3zAl9v5h9dL+EsUmHrtE/l2yklw+xiYnt5o CtH/8kGUvWWTuk6s7BCkMJ3ZX9H1DkAelU8NqADezarlkCFuwxbmznt8kLMLtD/i7zeU gr7Q9ckUbtL6ZJruvQV6jCrLEiOvsJIIr/1WqB74zG5zc0amOuVkbhj0zIyOzZ0eZfRQ c3gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=FamDpRRxOJ58SltchwNZF7P11BnxlXwApaRPCg7sEgs=; fh=o2bN/mr/Vuk5hpT/oNR/DwYXbeAgT6+/5I+un+9dbS4=; b=KwIh4swSojOVE+6sJbFKO0wMHQeIGE1dlNwKKs5lrUaDewAkqhESw3ryKrA5SBPX8V nTesR9EhdF036G3RYzE6BDBCxMAdGVtNq0/KX3/o14lPlHc6zh4dCisiO5RLxt2PEvrp fiTxTK9e/+6+i9rb8hlvs5adhjuH8jqADo8kGt67yUI8Skaerq+PuN5XlGoC6UBfmE9Z OrWvscxb+9hjdhp0FMjDwn4w6jZwAnK7b1OiwTQSp2xDqfsMkCBWRGpcM7en9GJqeBba CL9lGxXkYoV7u1gfyJWS9v5jpHQt+dQJhUbM0o8nwV2J4YgPHzmFdKHs0LvYIpXkZWq9 Wzeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="GTze/FHq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t186-20020a6381c3000000b00573f6ee58fasi3056814pgd.376.2023.09.15.04.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 04:16:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="GTze/FHq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 813C382A38D3; Thu, 14 Sep 2023 21:16:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231955AbjIOEP4 (ORCPT + 99 others); Fri, 15 Sep 2023 00:15:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231956AbjIOEPz (ORCPT ); Fri, 15 Sep 2023 00:15:55 -0400 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96AC02709 for ; Thu, 14 Sep 2023 21:15:46 -0700 (PDT) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-59c0442a359so9504797b3.0 for ; Thu, 14 Sep 2023 21:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694751346; x=1695356146; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=FamDpRRxOJ58SltchwNZF7P11BnxlXwApaRPCg7sEgs=; b=GTze/FHqzukfn7AScJn8BMG2yWF1Xw8G63BUAZ/Q4be0K4cde+lfKRyg2PTQCIRx7s WDr6+rlwAMCsi9GBEEpMb93yQb+Y/pZw79j2F66ZNnNcyV0eqiOBo1bfHIz69RYaB0hV n4B92N/u1hH+tp3lyQrLCSQV/XH8O4bX9/CDLdMWdRuUOihPDtLDrf9ZXV5NtxWTCIoZ xlCw6/8yr8+XEoti5UurASxT0dfLH9mM7vKW/drQ9vX5vq/wOpZZ1kMfGHkMPMnnPK2m seJNNNytyED/2Xr0fhPRXHBXuEQQmosIsBqwFeNRh6oGCfEUfRFihElwTHJYd6pKgANm hrEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694751346; x=1695356146; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FamDpRRxOJ58SltchwNZF7P11BnxlXwApaRPCg7sEgs=; b=otB2vrzsI5Dv9iWVo8HC7Ui7PASiC9F6YpzDzCFTtkIUuJweCXCV+sSlD8ysauOHa4 nfT06ZXOKP8fUwbPbh5+xk2BX0EUuCIO9USirBXay9fFENYC5YYSnX2lGKkJsD/kL89U FJ3AUg6cfrxXEu6zyTUZif//pY9yZ/E1KROdG1rfKmhPSMbQ3gsctPqyXWvszXYk+QPZ B42l8PfurJhxEA8a+AFwj/DMFRxNeEBfp8O3fxkwDE/lw3PLyO2btdnXMVgS5ZVd6kCF mujV13o0lUWUEbhjg7AmeYtWvj6ztQDX4Bq1gcMttUCl7h5CQhKEq2TLrbxJ+mguuaLg EaZw== X-Gm-Message-State: AOJu0YznJkY+elna+INL0koMSuWaMH+vW8OAAygg1QDSqzUykA3BYrlQ 7KzT27jSzajdmw5Pbj8m/QWgi6eYuaxAtDS7+kQnfQ== X-Received: by 2002:a25:ae1c:0:b0:d4d:f157:9673 with SMTP id a28-20020a25ae1c000000b00d4df1579673mr418753ybj.26.1694751345603; Thu, 14 Sep 2023 21:15:45 -0700 (PDT) MIME-Version: 1.0 References: <20230914152620.2743033-1-surenb@google.com> <20230914152620.2743033-3-surenb@google.com> <4F9BBE45-22D0-4F8D-BA56-CA3459998DC4@gmail.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 14 Sep 2023 21:15:31 -0700 Message-ID: Subject: Re: [PATCH 2/3] userfaultfd: UFFDIO_REMAP uABI To: Nadav Amit Cc: Andrew Morton , viro@zeniv.linux.org.uk, brauner@kernel.org, shuah@kernel.org, Andrea Arcangeli , lokeshgidra@google.com, Peter Xu , David Hildenbrand , Hugh Dickins , mhocko@suse.com, Axel Rasmussen , Mike Rapoport , Matthew Wilcox , Liam.Howlett@oracle.com, Jann Horn , zhangpeng362@huawei.com, bgeffon@google.com, kaleshsingh@google.com, ngeoffray@google.com, jdduke@google.com, linux-mm , linux-fsdevel@vger.kernel.org, Linux Kernel Mailing List , linux-kselftest@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 14 Sep 2023 21:16:02 -0700 (PDT) On Fri, Sep 15, 2023 at 4:04=E2=80=AFAM Nadav Amit w= rote: > > > > > On Sep 14, 2023, at 8:28 PM, Suren Baghdasaryan wro= te: > > > > On Thu, Sep 14, 2023 at 2:57=E2=80=AFPM Nadav Amit wrote: > >> > >> > >>> On Sep 14, 2023, at 8:26 AM, Suren Baghdasaryan w= rote: > >>> > >>> + if (!pte_same(ptep_clear_flush(src_vma, src_addr, src_pte), > >>> + orig_src_pte)) > >>> + BUG_ON(1); > >> > >> Just a minor detail regarding these few lines: > >> > >> Besides the less-than-ideal use of BUG_ON() here, I think that this co= de > >> assumes that the PTE cannot change at this point. However, as the PTE = was > >> still mapped at this point, I think the access and dirty bits can be s= et. > > > > At this point we are holding PTLs for both PTEs (see > > double_pt_lock()). Can a PTE be modified from under us in this > > situation? > > PTEs has several parts: access-control bits (e.g., writable), physical > frame number, software-only bits and log-bits. The log-bits, which are > =E2=80=9Caccess=E2=80=9D and =E2=80=9Cdirty=E2=80=9D on x86, track whethe= r the PTE has ever been used > for translation or write correspondingly. > > Without getting into all the subtleties (e.g., =E2=80=9Caccess" can be se= t > speculatively even if no actual access take place), as long as the PTE > is present, it might be used for access (and write if it is writable) > by other cores. The page-table locks are irrelevant here, because the > PTE is not updated by software, but it is updated by the CPU itself > during the page-walk/write. Ah, I see. I believe Jann also pointed this out in one of his comments and I didn't realize that. Thanks for the note! I'll see how I can rework this. > > -- > To unsubscribe from this group and stop receiving emails from it, send an= email to kernel-team+unsubscribe@android.com. >