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 EB236FA373D for ; Thu, 27 Oct 2022 22:56:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 064736B0072; Thu, 27 Oct 2022 18:56:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 014CB6B0073; Thu, 27 Oct 2022 18:56:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF7346B0074; Thu, 27 Oct 2022 18:56:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D19806B0072 for ; Thu, 27 Oct 2022 18:56:24 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A7D3CC1125 for ; Thu, 27 Oct 2022 22:56:24 +0000 (UTC) X-FDA: 80068239888.04.86A21C4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 44CA71A0006 for ; Thu, 27 Oct 2022 22:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666911383; 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=+4xRVRM6HYM4dL/jcPP/fB2OpyR5lIQBVcswO2a72qg=; b=R7nA4Qb6KCdmqgsQ6MWEaPa9qriiT9CkIozotHQPHbw9cxAUg6VaGS7cjvcQske89KMII/ sPVzGVmqLCC5+X5YZahbS/sVte+VI/yw4FX3/ew0VUrDE8xqizi2Eza3uIgB8Mxq70h/zu a0T+axMtmkQ6oTyEk0ZdGIztQuQJMVE= Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-590-1IpdKlmhNc2KSPiEg4TYDg-1; Thu, 27 Oct 2022 18:56:22 -0400 X-MC-Unique: 1IpdKlmhNc2KSPiEg4TYDg-1 Received: by mail-io1-f69.google.com with SMTP id n23-20020a056602341700b00689fc6dbfd6so2535721ioz.8 for ; Thu, 27 Oct 2022 15:56:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=+4xRVRM6HYM4dL/jcPP/fB2OpyR5lIQBVcswO2a72qg=; b=w6sWjh8TrfpOa9/BWUxBLzyyjw+t07sxsrFRfyNSMp4bWKgI3AZOtnwXN9DdaNaDcW p/gFz7Dj9ZdNuF+zg7BiDXVtqGXNfAqp6RxeQEevY5jAn0o/iyNf9C6zvzryO7KRFCxg XdjEoWgMbEP4kND+06O+mts28G4b2b/Cy7oEtVt1mv/g/FrWAyn7y5z9pbijCYsEL2tc cBS24x+jeXn/kdTPleUm131A5njUFHxunLl+C0G/9IJEru3yyE4YdQbYbM6lJiCU/zK/ 48vFwrXlmnJ1unxA2le37u5OpUzJ348RK1qIkbQrbKBWMdLPhZXD3ZOyll2RyICfwU0Q pBQA== X-Gm-Message-State: ACrzQf12UrYO4YeA06YRWM63dzXWot63oSMZVNS8XxdjP8kLeOd1dDy7 xGnQIJnlcbJKjNZa6gUtQkfTK0OvIIMEfsVOx8JD1fLdwTe1agh7y+vtEv1S5HKsfJt+jPu9bsw fEZ5ut5XLuXc= X-Received: by 2002:a02:2a04:0:b0:374:fe6c:2a96 with SMTP id w4-20020a022a04000000b00374fe6c2a96mr11316937jaw.109.1666911381472; Thu, 27 Oct 2022 15:56:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7T7Q5zxySQTKkcYSbAXC1Tm9HpqTCvGbn5Ns3K5+i3OYkTS7p+EAyxJDWdQMgah0eBwjsKVw== X-Received: by 2002:a02:2a04:0:b0:374:fe6c:2a96 with SMTP id w4-20020a022a04000000b00374fe6c2a96mr11316920jaw.109.1666911381260; Thu, 27 Oct 2022 15:56:21 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id j197-20020a0263ce000000b00369a91d1bd4sm1019725jac.138.2022.10.27.15.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 15:56:20 -0700 (PDT) Date: Thu, 27 Oct 2022 18:56:19 -0400 From: Peter Xu To: Hugh Dickins Cc: Yuanzheng Song , akpm@linux-foundation.org, gregkh@linuxfoundation.org, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH STABLE 5.10] mm/memory: add non-anonymous page check in the copy_present_page() Message-ID: References: <20221024094911.3054769-1-songyuanzheng@huawei.com> <3823471f-6dda-256e-e082-718879c05449@google.com> <8aad435-bdc6-816f-2fe4-efe53abd6e5@google.com> MIME-Version: 1.0 In-Reply-To: <8aad435-bdc6-816f-2fe4-efe53abd6e5@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666911384; a=rsa-sha256; cv=none; b=umUB+2vGUcS0G8TPeuBBrmrbVqh4JT+rQlN03FkQkKYjMo60xsWIDlzToAgHoPfAyWYxKO 4gv1NGjpScp7LxuJ9PU1Jg5bkIvkljmmeFn7P8IioPfVpjOFuWyOuSFH/tIw5gvd2gkIeR Xv362fn4ORA7dZzyOCAB4wJesOT6KjQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R7nA4Qb6; spf=pass (imf19.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666911384; 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=+4xRVRM6HYM4dL/jcPP/fB2OpyR5lIQBVcswO2a72qg=; b=ApW4eb7I42edjVdZU+GebT0ZuWZ93KdaP0A4e4SV0cDZPDsGI3KoPqOw/dprYVtCtmoEH+ vNKxuZkfiodVMhVYEsanz3690gSVC7iK+m1l3IuZVDubpkD0ApYDNc1Sl1IzQezyPHUjQh qrYdD2iwtiQ7e9pU5owN/lFwrL2a6AE= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 44CA71A0006 X-Rspam-User: X-Stat-Signature: f5s5sa54jzzz63co9zhz9njqndjx58tx Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R7nA4Qb6; spf=pass (imf19.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1666911384-467105 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Oct 27, 2022 at 02:58:02PM -0700, Hugh Dickins wrote: > Let me delete stable from the Cc, this discussion is not for stable. > > On Thu, 27 Oct 2022, Peter Xu wrote: > > On Wed, Oct 26, 2022 at 06:48:29PM -0700, Hugh Dickins wrote: > > > > > > And I imagined that the correct fix (short of going forward with David's > > > full changes) would be to back out to a context where one could add an > > > anon_vma_prepare(), then retry after that - involves dropping pt lock, > > > maybe gets nasty (tedious, anyway). > > > > Right, that looks a larger changeset with minimum benefit - the page is > > still inconsistent before fork(), and also for users don't fork() at all > > after the RO pin. > > Sorry, I don't understand any of what you're saying there: but you appear > to be saying ("larger changeset with minimum benefit") that my suggestion > would not be worth the effort - fair enough, but... > > > > > It looks to me Hugh's suggestion would be the best suite here for stable. > > Yuanzheng, what do you think? > > ... now you appear to be saying it would be worth the effort. Oh, > perhaps you're referring to just the change to check dst anon_vma: > perhaps, but I'm really having to guess at what you mean. Sorry for not being clear. Yes I was referring to that original idea of using dest->anon_vma. > > But none of that matters as much as below... > > > > > For the long term I think we should wait for David's further unshare work > > so gup_must_unshare() will work for page caches too while mapped private. > > I do wonder if in the long term we shall have to port all David's work > back to 5.15 and 5.10 (but I think there's yet more to come from him). > But set aside that thought for now... > > More urgently, in the short term: > > Peter, you've made no reference to David's mail, where he concludes that > Yuanzheng's !PageAnon patch is the appropriate one; and > David, you've made no reference to Peter's mail, where he concludes that > my doubts were correct, and it needs a different patch. > > You appear to disagree over whether a RO-pinned file page needs to > be copied at fork() time. I don't know, but I hope you can agree > on that (in the 5.10 and 5.15 context: maybe David is thinking of > the 6.0 context and Peter of the 5.10 context) before going further. > > (I'm hoping David is right, and I was plain wrong, since that's easiest.) For some reason I thought David was talking about the plan for the latest.. The major difference IIUC is whether we'll CoW for page caches during fork() with the old kernels or not with the two approaches (PageAnon check, or dst->anon_vma check). After a re-read and 2nd thought, I think David has a valid point in that we shouldn't have special handling of !anon pages on CoW during fork(), because that seems to be against the fundamental concept of fork(). So now I think I agree the !Anon original check does look a bit cleaner, and also make fork() behavior matching with the old/new kernels, irrelevant of the pin mess. Thanks, -- Peter Xu