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 706C2ECAAA1 for ; Mon, 5 Sep 2022 08:38:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E64DF6B00FE; Mon, 5 Sep 2022 04:38:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DED2A8D005A; Mon, 5 Sep 2022 04:38:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C67298D0050; Mon, 5 Sep 2022 04:38:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B093F6B00FE for ; Mon, 5 Sep 2022 04:38:58 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D8A5FAC419 for ; Mon, 5 Sep 2022 08:38:56 +0000 (UTC) X-FDA: 79877381472.19.31DCB17 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 4BC2B40052 for ; Mon, 5 Sep 2022 08:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662367135; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ILMwA9fkaPSQbnEjTCgZSueaFo6DDmAJP8o22EUbbXE=; b=G4JQS9IbI8KXtLw/0/yZSDapodiMzS/pzvnY6z2ON2+i6f+2UHdWb86bKj9kbXBcfK0zrH DAwdHtWA8iOPeqnLvQtQYN1kTlh1xNFRGjREU8pH7r4sEkBt9ndAn1hvjU9fznz/7a4wHO j06MRc5ozJtZKms06eeWSIw7eZTjv/g= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-38-tgSA8nZSNCGCDlIhaNcnmw-1; Mon, 05 Sep 2022 04:38:54 -0400 X-MC-Unique: tgSA8nZSNCGCDlIhaNcnmw-1 Received: by mail-wr1-f69.google.com with SMTP id a13-20020adfbc4d000000b00228631ddfafso474315wrh.9 for ; Mon, 05 Sep 2022 01:38:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=ILMwA9fkaPSQbnEjTCgZSueaFo6DDmAJP8o22EUbbXE=; b=eQ6I8Iq7wzLi3uf9Hu69oYQo4OfXifyMPWvhQRYNMuF2xfiEYN/AjV71JbynL7fzwf yOvoVpfvTaO0DFTQZWYLUJlKCYsobHyp1jxyKqCuX6AxwYUpWT1XITT7UNSmSP0Gouvf uJdo1/zqRNKViLDytH8v4Q0ZRcOv2VtinZ+wBgJXPZnSDN1wP40WHuSBNnCV1XMUB8P/ Ufw/bIQTE+U5RIZT/HOWgKdEAEUHeLIIPMcb6CaOwnOECDYI8xt9wR5N8oP2gw3f2Lqr cbKcHQFdsV7VEEjrapkX4aFxgYbVxfgwIdrhUS81c5dwi40wseqE/5Ni9qtNV16WXj93 xSgw== X-Gm-Message-State: ACgBeo3grLX/J6eY1dnxrSzz1Md3Ng7Xzzl4XhvYLENl6p6xknnb1Md3 gVxkpsLJc3/afUJ99kvrCzwFr9B7riXRjh6NlbrMGBhM8DbmVSoxkoA9DNIMAr0QvlurL3cD9kp YF1DRIEbFlh4= X-Received: by 2002:adf:edc9:0:b0:228:60de:1d4b with SMTP id v9-20020adfedc9000000b0022860de1d4bmr5046587wro.306.1662367133630; Mon, 05 Sep 2022 01:38:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR60WICcIrDNSZs4MSw41DvHhNAQ05OE2uoMX1kpOkCLtV4PSb7MnlZqTDufmIRJIblolcu2Ng== X-Received: by 2002:adf:edc9:0:b0:228:60de:1d4b with SMTP id v9-20020adfedc9000000b0022860de1d4bmr5046569wro.306.1662367133370; Mon, 05 Sep 2022 01:38:53 -0700 (PDT) Received: from ?IPV6:2003:d8:2f0d:ba00:c951:31d7:b2b0:8ba0? (p200300d82f0dba00c95131d7b2b08ba0.dip0.t-ipconnect.de. [2003:d8:2f0d:ba00:c951:31d7:b2b0:8ba0]) by smtp.gmail.com with ESMTPSA id bd17-20020a05600c1f1100b003a540fef440sm17340137wmb.1.2022.09.05.01.38.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Sep 2022 01:38:52 -0700 (PDT) Message-ID: <8e1aaa19-0d28-3381-3ec6-920a474f5f3f@redhat.com> Date: Mon, 5 Sep 2022 10:38:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH v1] mm/gup: adjust stale comment for RCU GUP-fast To: Aneesh Kumar K V , Yang Shi , Peter Xu Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, "Kirill A . Shutemov" , "Aneesh Kumar K . V" , Vlastimil Babka , Jerome Marchand , Andrea Arcangeli , Hugh Dickins , Jason Gunthorpe , John Hubbard References: <20220901072119.37588-1-david@redhat.com> <2368d91f-8442-076f-f33a-64b51b44825c@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662367136; a=rsa-sha256; cv=none; b=i3TDtsDsCkO90WXqBIc+wlFZcHEmgdXUkYy456MDPo5kO5L8YXN+nrrtJukqkXb/E1vDLC 1o15GDY4v47GIbRxrirfuG7PIIarSn+eDyHGG/XZrTTt8c515HCUXLaNlFcn4lWJR3YGHn J3FEAZxLqh/GYvl3PLSywMt7Nb6ZVfU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=G4JQS9Ib; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@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=1662367136; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ILMwA9fkaPSQbnEjTCgZSueaFo6DDmAJP8o22EUbbXE=; b=ago9EPyOVJa11Ng4af3Ltr1vikIrw2mSBV51toWn/Q26+wUOsRGHOVBXegoaKhkGf65lFy rOe52oaN0zYfjFaLLpjxlFb1kgWuvKYS886RHl/IuoJnqYgj5Vq/8WXMkp/UJOLbOba2vE tcoTzJEl8izQ/NNuHzLmVJGUvNIeMRY= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=G4JQS9Ib; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam01 X-Rspam-User: X-Stat-Signature: xstsqgsob1hptzzzm74y9kbmpo68jpje X-Rspamd-Queue-Id: 4BC2B40052 X-HE-Tag: 1662367136-768314 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 04.09.22 18:52, Aneesh Kumar K V wrote: > On 9/2/22 12:02 PM, David Hildenbrand wrote: >> On 01.09.22 20:35, Yang Shi wrote: >>> On Thu, Sep 1, 2022 at 11:07 AM Peter Xu wrote: >>>> >>>> On Thu, Sep 01, 2022 at 10:50:48AM -0700, Yang Shi wrote: >>>>> Yeah, because THP collapse does copy the data before clearing pte. If >>>>> we want to remove pmdp_collapse_flush() by just clearing pmd, we >>>>> should clear *AND* flush pte before copying the data IIRC. >>>> >>>> Yes tlb flush is still needed. IIUC the generic pmdp_collapse_flush() will >>>> still be working (with the pte level flushing there) but it should just >>>> start to work for all archs, so potentially we could drop the arch-specific >>>> pmdp_collapse_flush()s, mostly the ppc impl. >>> >>> I'm don't know why powperpc needs to have its specific >>> pmdp_collapse_flush() in the first place, not only the mandatory IPI >>> broadcast, but also the specific implementation of pmd tlb flush. But >>> anyway the IPI broadcast could be removed at least IMO. >>> >> >> pmdp_collapse_flush() is overwritten on book3s only. It either translates >> to radix__pmdp_collapse_flush() or hash__pmdp_collapse_flush(). >> >> >> radix__pmdp_collapse_flush() has a comment explaining the situation: >> >> >> + /* >> + * pmdp collapse_flush need to ensure that there are no parallel gup >> + * walk after this call. This is needed so that we can have stable >> + * page ref count when collapsing a page. We don't allow a collapse page >> + * if we have gup taken on the page. We can ensure that by sending IPI >> + * because gup walk happens with IRQ disabled. >> + */ >> >> >> The comment for hash__pmdp_collapse_flush() is a bit more involved: >> >> /* >> * Wait for all pending hash_page to finish. This is needed >> * in case of subpage collapse. When we collapse normal pages >> * to hugepage, we first clear the pmd, then invalidate all >> * the PTE entries. The assumption here is that any low level >> * page fault will see a none pmd and take the slow path that >> * will wait on mmap_lock. But we could very well be in a >> * hash_page with local ptep pointer value. Such a hash page >> * can result in adding new HPTE entries for normal subpages. >> * That means we could be modifying the page content as we >> * copy them to a huge page. So wait for parallel hash_page >> * to finish before invalidating HPTE entries. We can do this >> * by sending an IPI to all the cpus and executing a dummy >> * function there. >> */ >> >> I'm not sure if that implies that the IPI is needed for some other hash-magic. >> >> Maybe Aneesh can clarify. >> > > We still need the IPI for the hash. Another reason for architecture to override that > function is to help them use the right page size when flushing the TLB. Thanks for clarifying. So the radix variant wouldn't need the IPI anymore, once GUP-fast is handled differently, correct? -- Thanks, David / dhildenb