Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4027919pxf; Tue, 16 Mar 2021 04:05:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+Aj79SsP/bWlblrBAjL9UGdy5ZcUCah/OYwF+mXW4qofKTbMjURwiGV+auipGSQbNyrN7 X-Received: by 2002:a17:907:a04f:: with SMTP id gz15mr28762636ejc.293.1615892736061; Tue, 16 Mar 2021 04:05:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615892736; cv=none; d=google.com; s=arc-20160816; b=OeIYjfpySBpYWjKzXQoCXxDasM28/1cCya1osXZZl7apK7D4kOKdik9YJY9XteOKIb sogBalekdr1Y3LwGFf0g4+t0Gcfb6XzwcG6k2y+GrX9LaqcxtSRiiRQ0sjA+CIV2Tewm 04o2ROBRt1UlCcWvfXFWtLqlm8TfKuL/IDNIof3CJvYbopybfDw/0M/ul4nOZ90Hp8y5 xmmCwrWT8Rp3VbueBiU0r8DI7cA7hQmn5VHagbHa9NSo6NUEIgp4Y3K95546ub/+1M3S Bno1TVY7BJ8fJerxdXefmC1v0MQaVEXwoq6Ls4G4QGR8iSuFTIf813j1Btq25bVO/t9i yCMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=e5CCImco360RhJd/8dQ3gCq4TkMAWbyrmPrp5v0q8Vc=; b=Yg2FNZJVqd0pnuoVriRSyejvlARdrziWY21PL9NHi1SwG5EbKaimvHZYjaf2B/hjAA tpomK5tLjPMcRt20VTEfqBwcR1rY7642o1ClrXeFcU97kUR7SDp/2hOaGjE9WYMZMCVp KQoDRNmQrJ8g3pOrhgmKO/k5AVoosSJ6HmowrRv1oo5amx+dBNrJrIW6LEoSZ59qSTfC grX6O9Jj1dz7Ac9QLhAE1SIbIq9yTM+RcwmkMq4qMJq0JoyFtNWg1N7/3bR5DIOCb6Jc Vilb5NwYTVmvWhTYvjZQ+/hq1KqDELIZOkpMegNdgQKjRyyAzzlW+xkN4kbYDF1ysU8O VdNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=MKiRV5vM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si13342632ejc.493.2021.03.16.04.05.07; Tue, 16 Mar 2021 04:05:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=MKiRV5vM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233074AbhCOXmA (ORCPT + 99 others); Mon, 15 Mar 2021 19:42:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:51386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230455AbhCOXlp (ORCPT ); Mon, 15 Mar 2021 19:41:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98AF864F5E; Mon, 15 Mar 2021 23:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1615851698; bh=ZRw4LBv8GBdf5Sggo16rGV3091lb93cVl67xHbNT2sI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MKiRV5vMH9JlAlXD4ZUmR+e8lrd5u8nHdUPWTZJzi+ZFniCOUKLm4Mk7b+WF+22Xa sg7IUeo+f+EtjPEnf6/nKIYmoeeWU/Y7FveVfj6I4hFPkzbC07ZMVrmaD2QdZnoY2U QGk6jX5TQ9wkj5oOZBNuj7tw7mQfl86O2C6ATslU= Date: Mon, 15 Mar 2021 16:41:38 -0700 From: Andrew Morton To: Chris Goldsworthy Cc: Alexander Viro , Matthew Wilcox , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Laura Abbott Subject: Re: [PATCH v3] fs/buffer.c: Revoke LRU when trying to drop buffers Message-Id: <20210315164138.c15727adeb184313f5e7e9f6@linux-foundation.org> In-Reply-To: <2f13c006ad12b047e9e4d5de008e5d5c41322754.1610572007.git.cgoldswo@codeaurora.org> References: <2f13c006ad12b047e9e4d5de008e5d5c41322754.1610572007.git.cgoldswo@codeaurora.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Jan 2021 13:17:30 -0800 Chris Goldsworthy wrote: > From: Laura Abbott > > When a buffer is added to the LRU list, a reference is taken which is > not dropped until the buffer is evicted from the LRU list. This is the > correct behavior, however this LRU reference will prevent the buffer > from being dropped. This means that the buffer can't actually be dropped > until it is selected for eviction. There's no bound on the time spent > on the LRU list, which means that the buffer may be undroppable for > very long periods of time. Given that migration involves dropping > buffers, the associated page is now unmigratible for long periods of > time as well. CMA relies on being able to migrate a specific range > of pages, so these types of failures make CMA significantly > less reliable, especially under high filesystem usage. > > Rather than waiting for the LRU algorithm to eventually kick out > the buffer, explicitly remove the buffer from the LRU list when trying > to drop it. There is still the possibility that the buffer > could be added back on the list, but that indicates the buffer is > still in use and would probably have other 'in use' indicates to > prevent dropping. > > Note: a bug reported by "kernel test robot" lead to a switch from > using xas_for_each() to xa_for_each(). (hm, why isn't drop_buffers() static to fs/buffer.c??) It looks like patch this turns drop_buffers() into a very expensive operation. And that expensive operation occurs under the address_space-wide private_lock, which is more ouch. How carefully has this been tested for performance? In pathological circumstances (which are always someone's common case :() Just thinking out loud... If a buffer_head* is sitting in one or more of the LRUs, what is stopping us from stripping it from the page anyway? Then try_to_free_buffers() can mark the bh as buffer_dead(), declare success and leave the bh sitting in the LRU, with the LRU as the only reference to that buffer. Teach lookup_bh_lru() to skip over buffer_dead() buffers and our now-dead buffer will eventually reach the tail of the lru and get freed for real.