From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FC36CDB482 for ; Thu, 19 Oct 2023 20:44:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10287800AA; Thu, 19 Oct 2023 16:44:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08C838000B; Thu, 19 Oct 2023 16:44:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6EA0800AA; Thu, 19 Oct 2023 16:44:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D3F418000B for ; Thu, 19 Oct 2023 16:44:08 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8C973C121E for ; Thu, 19 Oct 2023 20:44:08 +0000 (UTC) X-FDA: 81363388176.25.A37C8D1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 6DB8210000E for ; Thu, 19 Oct 2023 20:44:06 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iXRAOVUj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697748246; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tUmq71SFaV76lBrVYh6+KvqO/bkIhCdS1UYE4ErabTM=; b=kbj4JuJ69wF5recP3hQP/oZ7ReWa4If22WBOqlzw19zzUN3IjFhFDQbawYo+CcTOHDpSld 1b9jUwlr7n7IUmT2nVhHNWUEHWH6upXAvSBCVFe+K/JwWwF+sV6aWEGT8Sa0nbKnS++m7n cZahrHxuFoKMW9A5L2rdikmZ99sUkIk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iXRAOVUj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697748246; a=rsa-sha256; cv=none; b=ULnPn0bkTd51+8o8UST2seRUA3RP45Na4wkxnnT7jtFD5Dh9vPPLIghIQ0NjIa46eGVcBO MxigKmJZgWkoEhSYoZoOFf2O9r8JZy2eqrBcGuOq4GPAGqVw57j5mapD1jLnUBxnWZhB/1 wAxx430hNEyqGdy/PCTTp4WxXw9k1NY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697748245; 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=iXRAOVUjY4DU4q9WMvQ7y5Y3ERW1dSspDO0OZlLL0WAZ2tyz2Th3jhAb9maNIhepDnFBGI vgIE1m4jfN9dttWjaZe2tJnREGSPFAE6zkxFwpTUO46+zmwn4BQSM15OG3i3wjetNtSfo6 OvjUrYL+VNNR+d2BNL1Q46zOvSbl3AM= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-249-apGP3O_AOMK3-qtPQAxPyw-1; Thu, 19 Oct 2023 16:43:59 -0400 X-MC-Unique: apGP3O_AOMK3-qtPQAxPyw-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-59bbd849b22so146847b3.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=NtiN0orz3ntqrIQbs429prYE+t0OlzWxlUpIRW0Ue2uxVlR+W96QrHl5jmUz/y2RKL VGf8P0bCna0Qns2Gdlcp0HiTqXkdDXMYiQ7XkFmKqj8tb/0T1g81rltFVXer4JLHFucv io1W6MPeo0QoC6ZtlfqJV+qKPQJY0ASf2b9deWo80KdKLPwW8ZQyOfGkXERrEFUyx00N gDNrc/Lsyr9tCqt2sEcHSX6nDKvVPMIHj5F9dSVNZkKmy6byzC7URzIEJYwygr30kxeT 7zy5iLHInWAQi4opuFY40dw924n/zQl75eM3/zMh0z3LsE94DtnFsDteeXEA25A4kfek guOA== X-Gm-Message-State: AOJu0Yzp1h37/4kX/n5tpHgxnxWtw9XehN4RJrno2dTxKJrvDromwKhU My+w0dC3MqOuhbx4/EE1RIcGUone6yK1Y++B0IcCKJvBg5iUXEOqIwD1onNQgjfONhDipsCEqS+ B9nuMaSd41yw= X-Received: by 2002:a05:690c:dc9:b0:5a7:b928:9e93 with SMTP id db9-20020a05690c0dc900b005a7b9289e93mr4048140ywb.5.1697748238850; Thu, 19 Oct 2023 13:43:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh6w+8ZXZ57cfOnUfzaZAee9HlNSSE1wHtnL/nhH2FMh9qNnuc/g7W0l/g4crX2wbdluxT3Q== 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 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: 6DB8210000E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cp7rwkye89i38myeb3zw1pdn3a89xtwf X-HE-Tag: 1697748246-476702 X-HE-Meta: U2FsdGVkX1+FRp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b+DR/1sMOa+9rtvEvYXle8VZtNW80tqc5di+YQRKQ04r8dOhBdpVsDsjPh+6Wyho6xL/qxh3BqjJwn3jhphi9kLx6Hm8fQDjOFYFdjQ9tQ3z0WyRy7U8YfGV6/+PvJLuCKrSRt8iIvmrRuE2FatNSYHi729TKTxnBQSrj3oGEO8cLhCxbzqf/jdU3tdoqIBribhMiq2YrcnEnLQ/5zJ8HHaD6RQJmjesTh1Xk/kOo9aii70GEwT/yeJigD4bhckhynLSkr0T5mY/4EFGTf8FbYYRp18DBLnb2soLYgcjG6yuyjAT7CdiThwmwSDbQyaOktuNwRc/76FLD3It00Xj X-Bogosity: Ham, tests=bogofilter, spamicity=0.000063, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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