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 E0175C433EF for ; Thu, 9 Dec 2021 09:30:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7764D6B0071; Thu, 9 Dec 2021 04:30:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FF176B0074; Thu, 9 Dec 2021 04:30:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C79E6B0075; Thu, 9 Dec 2021 04:30:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id 4CC836B0071 for ; Thu, 9 Dec 2021 04:30:26 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 13F2C185B44E6 for ; Thu, 9 Dec 2021 09:30:16 +0000 (UTC) X-FDA: 78897734832.31.7EB7690 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf14.hostedemail.com (Postfix) with ESMTP id CA4A7100004 for ; Thu, 9 Dec 2021 09:30:13 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10192"; a="224925419" X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="224925419" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2021 01:30:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,192,1635231600"; d="scan'208";a="606786633" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 09 Dec 2021 01:30:10 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id E245915C; Thu, 9 Dec 2021 11:30:16 +0200 (EET) Date: Thu, 9 Dec 2021 12:30:16 +0300 From: "Kirill A. Shutemov" To: Hugh Dickins Cc: Matthew Wilcox , Andrew Morton , Vlastimil Babka , William Kucharski , Christoph Hellwig , Mike Rapoport , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: delete unsafe BUG from page_cache_add_speculative() Message-ID: <20211209093016.eivzxmgr6c4twmus@black.fi.intel.com> References: <8b98fc6f-3439-8614-c3f3-945c659a1aba@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8b98fc6f-3439-8614-c3f3-945c659a1aba@google.com> X-Stat-Signature: qnc8aa31h7k3c4orn16g1sw7g7m597ce Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf14.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.126) smtp.mailfrom=kirill.shutemov@linux.intel.com X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: CA4A7100004 X-HE-Tag: 1639042213-158946 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 Wed, Dec 08, 2021 at 11:19:18PM -0800, Hugh Dickins wrote: > It is not easily reproducible, but on 5.16-rc I have several times hit > the VM_BUG_ON_PAGE(PageTail(page), page) in page_cache_add_speculative(): > usually from filemap_get_read_batch() for an ext4 read, yesterday from > next_uptodate_page() from filemap_map_pages() for a shmem fault. > > That BUG used to be placed where page_ref_add_unless() had succeeded, > but now it is placed before folio_ref_add_unless() is attempted: that > is not safe, since it is only the acquired reference which makes the > page safe from racing THP collapse or split. > > We could keep the BUG, checking PageTail only when folio_ref_try_add_rcu() > has succeeded; but I don't think it adds much value - just delete it. > > Fixes: 020853b6f5ea ("mm: Add folio_try_get_rcu()") > Signed-off-by: Hugh Dickins Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov