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 623EAC05027 for ; Mon, 6 Feb 2023 16:44:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4626B0072; Mon, 6 Feb 2023 11:44:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A740A6B0073; Mon, 6 Feb 2023 11:44:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93B966B0074; Mon, 6 Feb 2023 11:44:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 81DEB6B0072 for ; Mon, 6 Feb 2023 11:44:02 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3D21D1609C0 for ; Mon, 6 Feb 2023 16:44:02 +0000 (UTC) X-FDA: 80437439124.08.3904755 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id E86B71C0003 for ; Mon, 6 Feb 2023 16:43:58 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=f5z4jphw; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675701839; 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=6epnWjSAG9JBozBl82XEnHK98z89J7e0Ppw55ISjaD4=; b=SsMMYFQrveHOUizN9rSLj8eww6EcYGL9L1q5iDKsIkEo/73T3K3BUm7ZlKTIuih5l+Alet Y1zFNvYhkwi1Njsv9GHJq0qZ8e2ZE9xsM8EsKCqMwKUFEKqx6xc9BT29fst+k/J+Zkb3YK BS+tXKzgJdd2jinmC4hkLGeURMh+pcE= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=f5z4jphw; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675701839; a=rsa-sha256; cv=none; b=sSEW1Gsq8twmIPzbw2RdYIyfOJnbQ6BRh4zbchAXFPIkrKqRE+pgRSG1+MwvxaUF8u8jXM 7P9MKLvehr8oBQ/2mazcq93fsLnWuHqIH2E3dU3eq6IAkce2Il1AMU6Z/BbymrBy6nm+CB hCxgeheFIkoTzm3sMAU43ARJqd9fj1A= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6epnWjSAG9JBozBl82XEnHK98z89J7e0Ppw55ISjaD4=; b=f5z4jphwxYQIkdaaEygtB66SFE Xjc/HuPXEqjhNEvT/x/vPA168uX8+ZvAlkizofHYwIMf+Zo6JZXUhPNPKWNn+MTFgEWlxXpaPtc3T eJrEFtrd1bjIjjQyQOdbYQ3CR4YrCqeELnzu0EG974uDVAg9KOr4jyzz88CCdmOUZpwwM4W1TrBoz Kzlx34/JfBlRVvDUWenijrfA8Q+7CTHgUohjmohzCIz/329IXM1l+2MyLQJqXth4ysiWUR5mGqvid q6eFVJDXWqpjHqYL5Wpko9IuV+WfJ9I1EeZgWtQBMzdoErVSsGtOUh09UFhkfph2j5VrXKJSV9c6Z C5eckqIw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pP4aw-00Gusb-1t; Mon, 06 Feb 2023 16:43:54 +0000 Date: Mon, 6 Feb 2023 16:43:54 +0000 From: Matthew Wilcox To: David Hildenbrand Cc: "Yin, Fengwei" , linux-mm@kvack.org, dave.hansen@intel.com, tim.c.chen@intel.com, ying.huang@intel.com Subject: Re: [RFC PATCH v4 3/4] mm: add do_set_pte_range() Message-ID: References: <20230206140639.538867-1-fengwei.yin@intel.com> <20230206140639.538867-4-fengwei.yin@intel.com> <7c8d3d2c-35e3-5be4-684b-4b991a0adb8e@redhat.com> <400c5fb6-11ae-7771-07e0-538ebe652b2a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <400c5fb6-11ae-7771-07e0-538ebe652b2a@redhat.com> X-Rspamd-Queue-Id: E86B71C0003 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 3rh7udi34uf9r3pzbjyr8nycqibc6i45 X-HE-Tag: 1675701838-461688 X-HE-Meta: U2FsdGVkX1+Ze4JHEQjdR3y3CbqVh/0ErdFgoN1oSb79Z5SelTCnjfs+uTBJW1T/aL2lPWnIc9Jf5gpxic9pfMLXB6EtH0aaKB8z1iN5fHkB5TemHb9xtQT2qyjJ4ztnYvyzxegDnHONpSfJQFcGK8TBIImzFMOAsIw62ZWdmptxAY05SEmXKsVt7NyENvNT0amMQUkR9jX5D7P63V/EP7rv2SGcKkOCvZXE2UC8FmKxvnkr0FjxfrkTPBuaM5nRhmLUyUulrotHdQbYr9kXuT8TKoiDrqBQcPxxOukW2VG8YXHXcnVAgtM91cM0FmTMUieGpjXm6ah2yLwFvgwe6dQ2d3s+hccrQRSNXqG3ljNfl6hcmuC5PBWdZmEFCewC6B/OBDWvNVsfDZ0gKaTZPEVxBV2il8jgIJVoiyGUHD1IE2O3hndUV4EDlBhftT+VwbQRtJ74j8GCRIAucwQg5D+DFwbh2Cb/CnNnvNwohg72wO3rQUDBxErpUGC9BaU0S6zZ5rsmtPuZxdaaibwEeBY+yRztQfuPQFACaKTki0yQpKqYOO6Cf3ZYbmrG+lQ2qSWdu+WfHuaHoZjffRmpMfieO5Z0lxVraU1e/RsvWv4hf3Jta6xaqO8YeP/gZECDyJsjDuUkOCPVaIKzl96qSCFXQeTSkVwWOkXuNgUcB5qqVZW4nqXY5CqQpT6a+E9jJ7/uYV8hfAkVz3sPevAAgXmdhEcnjfyM/9+oUBTU6OhqRSWn4CLuvHN/fPDw0cUBOJBWbnLayYTXybdUoQdcn+nwgZADG5DyX7Fp+tW0u2Ch3nt1pOJG5bzDSGGqaxtJhpRBNO0UB2VrNWMoM2vr1LfX8Z/mEzkKy9dHkribBjJ3+tLn0MOO86ozkUZqRVSwwJwphoYDLQYuo+3Q8luIihmmvgb1YlMFlvLs/7crh9AkV6F/+ZrrJYEiKhUMt2dFkamPnGy9yYkvt86m7F9 EQ6WdUAz w2N6jrvbk/1c4x3fN5oEojGCcFN/x/p0iz/ujnLN4XDWeDLZb7rTJNbL1iNHZuVUzO8EjGo4GIWiFomsAKISi9UgRYK6t8rwrsALxcvJpSv2ej5eOH4WFXKkUvVIWEaum77bhlolzPy4pYVsLx/ClUOZSsbapVwGpOtT5qWvW6AKJb8LvK9ljVPAG7+imqqQj+ob06kdOmJ0LORM= 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 Mon, Feb 06, 2023 at 05:35:55PM +0100, David Hildenbrand wrote: > On 06.02.23 17:33, Matthew Wilcox wrote: > > On Mon, Feb 06, 2023 at 04:13:44PM +0100, David Hildenbrand wrote: > > > > > The handling of cow pages is still very clunky. > > > > > folio_add_new_anon_rmap() handles anonymous large folios just fine. I > > > > > think David was looking at current code, not the code in mm-next. > > > > OK. Let's wait for further comment from David. > > > > > > As I raised, page_add_new_anon_rmap() -> folio_add_new_anon_rmap() can be > > > used to add a fresh (a) PMD-mapped THP or (b) order-0 folio. > > > > > > folio_add_new_anon_rmap() is not suitable for PTE-mapping a large folio. > > > Which is what we are intending to do here unless I am completely off. > > > > I think you are. While the infrastructure here handles large folios > > which are not PMDs, there's nobody who will allocate such a thing, so > > there is no problem. Right> > > And that's precisely what I want to have fenced off here. I want that > function to complain instead of silently doing the wrong thing. If this were a widely called function, I'd agree. But there are two callers of do_set_pte; one in filemap.c and one in memory.c. It's overcautious and has created huge churn in this patchset. If you're really that concerned, stick a VM_BUG_ON() in folio_add_new_anon_rmap() instead of making weird stuff happen in set_pte_range().