Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp609562rdb; Thu, 19 Oct 2023 13:45:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTVGRXlwIJ9TL9K8N/lNidsFwy1XJ+m96AgZvLz6e9JD2iU2oTux5jeA6wagp7XGHejD3S X-Received: by 2002:a05:6a20:4292:b0:17a:eddb:acc2 with SMTP id o18-20020a056a20429200b0017aeddbacc2mr3530073pzj.46.1697748307941; Thu, 19 Oct 2023 13:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697748307; cv=none; d=google.com; s=arc-20160816; b=yj+YbVh9frHoC9UnIViEBfPs6D+PvrI7DzLylDaQBuv2D0ddbrPhoRzWpwdKqLHzGP +Ju2i1zVz7rHn/iuKGDhilaZYMKNaGn6bK5CM6YvNbP7qXv7TC8zAOx6ql8A9paNPkyj OEfQAX0VfTgwhUEQxzsZbTJyGYKJa+IxnvZb8UYOe+OHTZaglRZ50+9S5tj4m4PLziE5 +mIAoJcXuRDoVsz6jazQlMfhlRWUwPNNzZ9jAS+U/7xLFIf1y7d7zrtX+YSoVv5gsd16 ESx1fTY3lu/SU91ewBRT0U1/ra6nOK7EV/4QAVA4F0QwCsQjOp4dXR4NeUBIGe+Gyv1v Dy+Q== 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=tUmq71SFaV76lBrVYh6+KvqO/bkIhCdS1UYE4ErabTM=; fh=kQ+RmjS20afp1cN5P5GXwjuqZCokE8QieAoywoKLFak=; b=LIWJ8bzXVf7zlVPBPY/RNvq37517dQfXOVUi+ayb+Wyx/kcekFdYwZgOj80nR6bWu+ uVXEwzXKWjdGEFBaXr2+ZrUtsxjrT9pGeaZ11jyisM+3Rgzi1lfP87rnxalCNPOwbdtA 5irQcWKS+BTrk+yXK2mFxozeoAV1Ywhe5tXRKu/B1dvnvXo1EI5upIImX4UkmRO9bpGE 4eosrgXDc3fwYdf2afXMuOjPcTZbcERCY+mAoDTQ2gTmPzdHrQtEvu7MfmZlYvNxSjYj Ov1xIXr6jT8rnlSq0fccZ5yI7s07GkDPVWReu8ZjKVZmH0qilQfjaLnNJCJwrb2mL0gU zPUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OF6EwuC2; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id m129-20020a633f87000000b00577ae8b603fsi380824pga.314.2023.10.19.13.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 13:45:07 -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=@redhat.com header.s=mimecast20190719 header.b=OF6EwuC2; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 938B2827C19C; Thu, 19 Oct 2023 13:45:06 -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 S1346553AbjJSUpE (ORCPT + 99 others); Thu, 19 Oct 2023 16:45:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346397AbjJSUpD (ORCPT ); Thu, 19 Oct 2023 16:45:03 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B85612F for ; Thu, 19 Oct 2023 13:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697748251; 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=tUmq71SFaV76lBrVYh6+KvqO/bkIhCdS1UYE4ErabTM=; b=OF6EwuC2j9NM+CVaVDAlqtuZqVve4aDnYVQhEf8M1YvXmULARlzpEiuIbsFO4S8TOrW/E6 rd5Uq6wVVVYovP+MDEH3FK51BOhPNwOP5vySqgu/fxsduNo35rkezlOXU0P60TZicqUCI1 qQuaqdn7bNDZEt3bCud610MYajA6fos= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-249-ZQMDGzKmNQmzZtrAx86uCQ-1; Thu, 19 Oct 2023 16:43:59 -0400 X-MC-Unique: ZQMDGzKmNQmzZtrAx86uCQ-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-59bbd849b22so146957b3.0 for ; Thu, 19 Oct 2023 13:43:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697748239; x=1698353039; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tUmq71SFaV76lBrVYh6+KvqO/bkIhCdS1UYE4ErabTM=; b=REdZlPtpL2/xKETdOyW3is8IqS7C9wP+fzyqCZXSOEVXQRX9YSRWY0Lp2ufR2LryAN SmppAalx+ZQvW9/o2XqQld/qgf9XWyw7AUWoeIlU9EIae+u7Ai+c9C2H5EaO+Sqf0q/b n7zK7TWG2iYbay4b3cUtV5zPxyLtAtzZet8jDCIXXB/NPEKA4ji3ZJgbAa+KnatUDkwg fDNQY7ulSQSS+Ku+uGGdpAkFaCTI2YkILpPJ9TU+3BM/Ygf9+9PNN7klREiPKYjP4Bzi AkSERiBmy8WHSDneyCQ6ElKa0EWuRARok00Ozknzi84vy/SgZx2ou/rvUq3ZFQBsDgKE HcJQ== X-Gm-Message-State: AOJu0YxhS+CO2UVIeJIKhwm3pV3mivvC5aiCEQBUCGl21DSLdPT/x+sS 0frJ468USdfBB7LoiwJTgUi1zQQpxq3+lJktirahubPwTeoVPa6Cdwn8XWqYkldqvH8cvumxLdE MYz5QU72+Or3BYjSF3iGKdkOz X-Received: by 2002:a05:690c:dc9:b0:5a7:b928:9e93 with SMTP id db9-20020a05690c0dc900b005a7b9289e93mr4048164ywb.5.1697748238867; Thu, 19 Oct 2023 13:43:58 -0700 (PDT) X-Received: by 2002:a05:690c:dc9:b0:5a7:b928:9e93 with SMTP id db9-20020a05690c0dc900b005a7b9289e93mr4048123ywb.5.1697748238545; Thu, 19 Oct 2023 13:43:58 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id bi12-20020a05620a318c00b00772662b7804sm82248qkb.100.2023.10.19.13.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 13:43:58 -0700 (PDT) Date: Thu, 19 Oct 2023 16:43:56 -0400 From: Peter Xu To: Suren Baghdasaryan Cc: David Hildenbrand , Lokesh Gidra , akpm@linux-foundation.org, viro@zeniv.linux.org.uk, brauner@kernel.org, shuah@kernel.org, aarcange@redhat.com, hughd@google.com, mhocko@suse.com, axelrasmussen@google.com, rppt@kernel.org, willy@infradead.org, Liam.Howlett@oracle.com, jannh@google.com, zhangpeng362@huawei.com, bgeffon@google.com, kaleshsingh@google.com, ngeoffray@google.com, jdduke@google.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v3 2/3] userfaultfd: UFFDIO_MOVE uABI Message-ID: References: <205abf01-9699-ff1c-3e4e-621913ada64e@redhat.com> <12588295-2616-eb11-43d2-96a3c62bd181@redhat.com> <8d187891-f131-4912-82d8-13112125b210@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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, 19 Oct 2023 13:45:06 -0700 (PDT) On Thu, Oct 19, 2023 at 01:02:39PM -0700, Suren Baghdasaryan wrote: > Hi Folks, > Sorry, I'm just catching up on all the comments in this thread after a Not a problem. > week-long absence. Will be addressing other questions separately but > for cross-mm one, I think the best way forward would be for me to > split this patch into two with the second one adding cross-mm support. > That will clearly show how much additional code that requires and will > make it easier for us to decide whether to support it or not. Sounds good, thanks for that extra work. > TBH, I don't see the need for an additional flag even if the initial > version will be merged without cross-mm support. Once it's added the > manpage can mention that starting with a specific Linux version > cross-mm is supported, no? It's about how an user app knows what the kernel supports. On kernels that only support single-mm, UFFDIO_MOVE should fail if it found ctx->mm != current->mm. I think the best way to let the user app be clear of what happened is one new feature bit if cross-mm will be supported separately. Or the userapp will need to rely on a specific failure code of UFFDIO_MOVE, and only until the 1st MOVE being triggered. Not as clear, IMHO. > Also from my quick read, it sounds like we want to prevent movements > of pinned pages regardless of cross-mm support. Is my understanding > correct? I prefer that, but that's only my 2 cents. I just don't see how remap can work with pin. IIUC pin is about coherency of processor view and DMA view. Then if so the VA is the only identifier of a "page" for an user app because real pfn is hidden, and remap changes that VA. So it doesn't make sense to me to remap a pin in whatever form. For check pinning: I think I used to mention that it may again require proper locking over mm.write_protect_seq like fork() paths. No, when thinking again I think I was wrong.. write_protect_seq requires mmap write lock, definitely not good. We can do what David mentioned before, after ptep_clear_flush() (so pte is cleared) we recheck page pinning, if pinned fail MOVE and put the page back. Note that we can't do that check after installing it into dest pgtables, because then someone can start to pin it from dest mm already. Thanks, -- Peter Xu