Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1400357rbb; Mon, 26 Feb 2024 08:07:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXP9avk998kYoNWzwGyFmDid8iQs7zOfuB72NwReswdo8nR+4XFMSG7TjzxT3eoYluWuGa8WRg4meIlX+VvKYNaE0JNWKD3lwAYNDJ27g== X-Google-Smtp-Source: AGHT+IHLK5W74B2UghtB15/Gih1rrIIhSEDZoWPwXHrKMDzFigKp1ba/N4wU37cFHWtmDZ3hV8JW X-Received: by 2002:a17:906:e204:b0:a3f:7d84:4d2e with SMTP id gf4-20020a170906e20400b00a3f7d844d2emr5331146ejb.30.1708963668351; Mon, 26 Feb 2024 08:07:48 -0800 (PST) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m11-20020a170906580b00b00a3e422fea19si2285452ejq.159.2024.02.26.08.07.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:07:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81866-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=casper.20170209 header.b=SN5FmGYX; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-81866-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81866-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 25B0F1F2CF4E for ; Mon, 26 Feb 2024 16:07:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 598E112C532; Mon, 26 Feb 2024 16:07:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SN5FmGYX" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBAE2129A95 for ; Mon, 26 Feb 2024 16:07:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708963630; cv=none; b=p/oabK9a0jJWbgxCgJpqd+11BJiV/Pl6qJ0RdYIUBM2gh9qEMdMJgBwLk1qKgoqxpHR1z2UJqjmIPIL3GWUWTzWkd1dxv9bHH3czbV/j6pxndfkGPEinn92WWU4EFdlPMbry4IUy2H4Pty4TkX68XGASOM6yHizkQnvTYuzYwf4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708963630; c=relaxed/simple; bh=rZgjS7hx97FiN+TOw76foGho3vxsXG12mQSj5fGDka4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=u1pphwD68WEW+z+GNo8pOSrpKH2e6dPCWH8mLglL0E5crb9hCAQptpC+TNHP1XkN5P9+c/ICGoJREUaASwJsUakO+IG30ubv8w2eBptb+GrXg8js5zlRJCzjV8i/2wXCZ8HmXUhUOTBKq5M5UF1M0m9GfCItv2RrqVUL/Ym7uNE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=SN5FmGYX; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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=fhdGu3trmRJDR0pxGd/fdG/MnSc6CZnEt17ipVogjy8=; b=SN5FmGYX0apBuYqIHPw4slOL0R koA8vDKaZtjnbcjQ83HgtRDdOTUG/ke+0awUEAjSy5DCNmrA1mlrWu8JlDMFydOPlpWTpksRJcy+L gES0VhCCOXtq5kfEHmDkqF/iPpeCTtiBcPuqAPQu/FmUKHx9lwwYUnoBLSoKWyWP7DjyuIf/mP4tw a9f1A1XAxcPz9c3BRiQKNfUJ7WvpK3aEiXStOlOPaILJ3Vy3D6cQ3VRN2G8zLL9lHjcu7iWFAchwl H4isc7EJAMzBC7PmRJvoGYJFIzHIVUqLyHOVpdqfFUIulARBMhP9HStr2DNybrBTHhGiZ0YKyi3oN JGqP2vdw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1redVS-0000000Hajc-01ec; Mon, 26 Feb 2024 16:07:06 +0000 Date: Mon, 26 Feb 2024 16:07:05 +0000 From: Matthew Wilcox To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton Subject: Re: [PATCH v2 1/2] mm/memfd: refactor memfd_tag_pins() and memfd_wait_for_pins() Message-ID: References: <20240226141324.278526-1-david@redhat.com> <20240226141324.278526-2-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240226141324.278526-2-david@redhat.com> On Mon, Feb 26, 2024 at 03:13:23PM +0100, David Hildenbrand wrote: > + xas_for_each(xas, folio, ULONG_MAX) { > + if (!xa_is_value(folio) && memfd_folio_has_extra_refs(folio)) > xas_set_mark(xas, MEMFD_TAG_PINNED); .. we decline to tag value entries here ... > @@ -95,20 +90,15 @@ static int memfd_wait_for_pins(struct address_space *mapping) > > xas_set(&xas, 0); > xas_lock_irq(&xas); > - xas_for_each_marked(&xas, page, ULONG_MAX, MEMFD_TAG_PINNED) { > + xas_for_each_marked(&xas, folio, ULONG_MAX, MEMFD_TAG_PINNED) { > bool clear = true; > > - cache_count = 1; > - if (!xa_is_value(page) && > - PageTransHuge(page) && !PageHuge(page)) > - cache_count = HPAGE_PMD_NR; > - > - if (!xa_is_value(page) && cache_count != > - page_count(page) - total_mapcount(page)) { > + if (!xa_is_value(folio) && > + memfd_folio_has_extra_refs(folio)) { .. so we don't need to test it here because we'll never see any value entries. No?