From patchwork Tue Sep 11 17:28:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 11327 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4E33A23E00 for ; Tue, 11 Sep 2012 17:29:09 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 9B4183D00564 for ; Tue, 11 Sep 2012 17:29:08 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so1305046iea.11 for ; Tue, 11 Sep 2012 10:29:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-ironport-av:from:to:date:message-id:x-mailer:cc:subject :x-beenthere:x-mailman-version:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-gm-message-state; bh=32ASrhaufL/QbgXjvKeT+E26d8zsNgbPz38D61ww4fM=; b=HJ7iBKx3TM8mTb+Z4J52QhgdZ8KrcvPGY7ndLs5HhJVzk6xioTHXr2RnF/TCKHWqxp 0mNaPr0nKUg9E81rON9oEFQCiD1FplTDXWG9MV62oiojfeOH4d5yJrpXDmSs+AgALNbk 3zENto790siM8kjO28kJJXltdSaox0Li75vq5e+8JDGeW54s/3KmHFC6wNgVpy9nLrz3 kNvCB9RqlGduDvdbU+h5/N1jpsJwWmJp+2ggiy7T9ogg2W9jJRlClALDGsn4uPAKEcVY DRwRxqVFCJ59ZYuVDrJG9ssaoQWKP5BEgg1I86zrX9rrjATPP76TP9TS63yh8eMTZEV/ /E5w== Received: by 10.50.195.134 with SMTP id ie6mr17879087igc.28.1347384548356; Tue, 11 Sep 2012 10:29:08 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp25628igc; Tue, 11 Sep 2012 10:29:07 -0700 (PDT) Received: by 10.204.157.18 with SMTP id z18mr5215278bkw.16.1347384546401; Tue, 11 Sep 2012 10:29:06 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id is14si10323583bkc.30.2012.09.11.10.28.59; Tue, 11 Sep 2012 10:29:06 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TBUGf-00069F-43; Tue, 11 Sep 2012 17:28:57 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TBUGd-000698-JT for linaro-mm-sig@lists.linaro.org; Tue, 11 Sep 2012 17:28:55 +0000 X-IronPort-AV: E=McAfee;i="5400,1158,6832"; a="235380270" Received: from pdmz-ns-snip_115.254.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.115.254]) by wolverine01.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Sep 2012 10:28:54 -0700 Received: from lauraa-linux.qualcomm.com (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id F239F10004AA; Tue, 11 Sep 2012 10:28:53 -0700 (PDT) From: Laura Abbott To: Alexander Viro Date: Tue, 11 Sep 2012 10:28:49 -0700 Message-Id: <1347384529-5862-1-git-send-email-lauraa@codeaurora.org> X-Mailer: git-send-email 1.7.8.3 Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-fsdevel@vger.kernel.org Subject: [Linaro-mm-sig] [RFC][PATCH] fs/buffer.c: Revoke LRU when trying to drop buffers X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQkAoxVGGg7A5CKZlZhBsMLlKpTvLDh23MUEHt/PsGZnc7R9fdD9rfi4sIGja4B5HZ3TorLT 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 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. Signed-off-by: Laura Abbott --- fs/buffer.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/fs/buffer.c b/fs/buffer.c index ad5938c..daa0c3d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1399,12 +1399,49 @@ static bool has_bh_in_lru(int cpu, void *dummy) return 0; } +static void __evict_bh_lru(void *arg) +{ + struct bh_lru *b = &get_cpu_var(bh_lrus); + struct buffer_head *bh = arg; + int i; + + for (i = 0; i < BH_LRU_SIZE; i++) { + if (b->bhs[i] == bh) { + brelse(b->bhs[i]); + b->bhs[i] = NULL; + goto out; + } + } +out: + put_cpu_var(bh_lrus); +} + +static bool bh_exists_in_lru(int cpu, void *arg) +{ + struct bh_lru *b = per_cpu_ptr(&bh_lrus, cpu); + struct buffer_head *bh = arg; + int i; + + for (i = 0; i < BH_LRU_SIZE; i++) { + if (b->bhs[i] == bh) + return 1; + } + + return 0; + +} void invalidate_bh_lrus(void) { on_each_cpu_cond(has_bh_in_lru, invalidate_bh_lru, NULL, 1, GFP_KERNEL); } EXPORT_SYMBOL_GPL(invalidate_bh_lrus); +void evict_bh_lrus(struct buffer_head *bh) +{ + on_each_cpu_cond(bh_exists_in_lru, __evict_bh_lru, bh, 1, GFP_ATOMIC); +} +EXPORT_SYMBOL_GPL(evict_bh_lrus); + void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long offset) { @@ -3052,6 +3089,7 @@ drop_buffers(struct page *page, struct buffer_head **buffers_to_free) bh = head; do { + evict_bh_lrus(bh); if (buffer_write_io_error(bh) && page->mapping) set_bit(AS_EIO, &page->mapping->flags); if (buffer_busy(bh))