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 0E0A4C43334 for ; Thu, 21 Jul 2022 18:51:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55F806B0071; Thu, 21 Jul 2022 14:51:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50E6D6B0073; Thu, 21 Jul 2022 14:51:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D7116B0074; Thu, 21 Jul 2022 14:51:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3098A6B0071 for ; Thu, 21 Jul 2022 14:51:19 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 09E3BA0965 for ; Thu, 21 Jul 2022 18:51:19 +0000 (UTC) X-FDA: 79711999878.19.ACCFDF2 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf17.hostedemail.com (Postfix) with ESMTP id 951794009B for ; Thu, 21 Jul 2022 18:51:18 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id l14so1968206qtv.4 for ; Thu, 21 Jul 2022 11:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ABlARo1q4W8MWl8fMSyyIWAkJhcwdZqRLERUMRVV8y0=; b=a3Dipqi7DP4aUkldrHp93ne1O6cTrWtFJpNvlTOIVlXo01XvWSk4dz1tX3rtPQH3F2 jAZAdCSavV3Sqgbsz0881u6GS2ltM95tIgUSEsp0f4tJQdjSNgtsu7Jm0vYtk0N2CT3v Aif0YgWwWfuK44GRHXwEJRP03Ftyu1B4VkWa6AXBbpGhQcxyIz58MrwLQXzV7/YOGDWD JA9n9g/1CRGRGhplF8rk7GYAdQ3ph3PTTW9VPSa4A+IG/q+1eI6r6yd63bvqVxvRoThu CFd4/soAUrj26JEa+N7OTRsMBMcMiPKeKZJ6e4cI5qyemzqeYxtA9kaepAZ6wNVIN7X3 sMPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ABlARo1q4W8MWl8fMSyyIWAkJhcwdZqRLERUMRVV8y0=; b=w0i0sWahvz4izvDvZ7hx+DM00O1N1XkckZE8I7IA6Glz3dg+aKfqYONWchk7fHmPK4 N+0V4gyZQvX1Butm6cHYS77hryvHrHTyvLkdhK5Q75l/itkC0GoNpwyrNtI3nPSN6tBw dbeR9keuCdDr7eO2GkGsaem0MixRmGJ3JBCZxHxTCOOLhBRlrdHLWeDH310EQhhFml5M xLgYHH5zbimpulTxSfoSHOuzR+fkqpOtHxXtglw+s1BWTbuZc1kCtbj4c9yWopkyb3nO pahbmTB3ebZePCdraO++m9jN61ZvbPY5zu6fdBpbIqfijsEhlQHNsNMgDW0jKgP9hXhj omYQ== X-Gm-Message-State: AJIora9IhXoxPUK752YIrqOSRyw0bG1JTx3zQkzBGfzbkwf/K9z90l4q ck7IY65cyIPVJVgmblkODKkkmA== X-Google-Smtp-Source: AGRyM1tSQawsbfCG3JVFskJrFAyZkEyE7wpSkmlKeLjG/ZzroPfTxIM/UKxdVXtcFB6JavtqQFxOGg== X-Received: by 2002:ac8:5a12:0:b0:31e:f233:50f1 with SMTP id n18-20020ac85a12000000b0031ef23350f1mr15963077qta.229.1658429477857; Thu, 21 Jul 2022 11:51:17 -0700 (PDT) Received: from ziepe.ca ([142.177.133.130]) by smtp.gmail.com with ESMTPSA id q5-20020a05620a038500b006b5e833d996sm1745532qkm.22.2022.07.21.11.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 11:51:17 -0700 (PDT) Received: from jgg by jggl with local (Exim 4.94) (envelope-from ) id 1oEbGW-00022g-2R; Thu, 21 Jul 2022 15:51:16 -0300 Date: Thu, 21 Jul 2022 15:51:16 -0300 From: Jason Gunthorpe To: Dan Williams Cc: Muchun Song , Matthew Wilcox , akpm@linux-foundation.org, jhubbard@nvidia.com, william.kucharski@oracle.com, jack@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, ruansy.fnst@fujitsu.com, hch@infradead.org Subject: Re: [PATCH] mm: fix missing wake-up event for FSDAX pages Message-ID: <20220721185116.GC6833@ziepe.ca> References: <20220704074054.32310-1-songmuchun@bytedance.com> <62ccded5298d8_293ff129437@dwillia2-xfh.notmuch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <62ccded5298d8_293ff129437@dwillia2-xfh.notmuch> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658429478; 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=ABlARo1q4W8MWl8fMSyyIWAkJhcwdZqRLERUMRVV8y0=; b=GEpvjo2pwa8/O+Dl1xJKJ1CM3dnFcRE5vWG9/PHN82cG4gi9uGq+C0qm6LWoAFUxRzJZCV tXlqzGdazeyjJuUNTRM2g7JUEPCpPiRzyFoVBoyfNRQXArMdaRcf1A6H5+Nn/0uI8I5+rr eB/RWBlwh+e/z9zLKIDRRsq1eU/XNZ4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658429478; a=rsa-sha256; cv=none; b=MeHg0Edw5T2BJsfcXKi77CeVBZQLDFMmO6lF9GIHlGKGN3v4Z1Ycu+Os6Tz9CElVKXFqJg VTppvjCpFr9g4Q02+87AazOsPuCnCRY1pNbyRHV0JBZDtEaUBOBX6odrnfhHYE7Vcf7GyV +nAQkKnWG40izco73M+uHVF0Bb4vh1o= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=a3Dipqi7; dmarc=none; spf=pass (imf17.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.160.176 as permitted sender) smtp.mailfrom=jgg@ziepe.ca X-Stat-Signature: 3y33jhsme67f9xqxdgi1bhxdmsbgoiaa X-Rspamd-Queue-Id: 951794009B Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=a3Dipqi7; dmarc=none; spf=pass (imf17.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.160.176 as permitted sender) smtp.mailfrom=jgg@ziepe.ca X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1658429478-832824 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, Jul 11, 2022 at 07:39:17PM -0700, Dan Williams wrote: > Muchun Song wrote: > > On Mon, Jul 04, 2022 at 11:38:16AM +0100, Matthew Wilcox wrote: > > > On Mon, Jul 04, 2022 at 03:40:54PM +0800, Muchun Song wrote: > > > > FSDAX page refcounts are 1-based, rather than 0-based: if refcount is > > > > 1, then the page is freed. The FSDAX pages can be pinned through GUP, > > > > then they will be unpinned via unpin_user_page() using a folio variant > > > > to put the page, however, folio variants did not consider this special > > > > case, the result will be to miss a wakeup event (like the user of > > > > __fuse_dax_break_layouts()). > > > > > > Argh, no. The 1-based refcounts are a blight on the entire kernel. > > > They need to go away, not be pushed into folios as well. I think > > > > I would be happy if this could go away. > > Continue to agree that this blight needs to end. > > One of the pre-requisites to getting back to normal accounting of FSDAX > page pin counts was to first drop the usage of get_dev_pagemap() in the > GUP path: > > https://lore.kernel.org/linux-mm/161604048257.1463742.1374527716381197629.stgit@dwillia2-desk3.amr.corp.intel.com/ > > That work stalled on notifying mappers of surprise removal events of FSDAX pfns. We already talked about this - once we have proper refcounting the above is protected naturally by the proper refcounting. The reason it is there is only because the refcount goes to 1 and the page is re-used so the natural protection in GUP doesn't work. We don't need surprise removal events to fix this, we need the FS side to hold a reference when it puts the pages into the PTEs.. > So, once I dig out from a bit of CXL backlog and review that effort the > next step that I see will be convert the FSDAX path to take typical > references vmf_insert() time. Unless I am missing a shorter path to get > this fixed up? Yeah, just do this. IIRC Christoph already did all the infrastructure now, just take the correct references and remove the special cases that turn off the new infrastructure for fsdax. When I looked at it a long while ago it seemd to require some understanding of the fsdax code and exactly what the lifecycle model was supposed to be there. Jason