From patchwork Fri Aug 31 20:46:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 11135 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 2613B23E02 for ; Fri, 31 Aug 2012 20:47:26 +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 7B6F8A19359 for ; Fri, 31 Aug 2012 20:46:46 +0000 (UTC) Received: by ieak11 with SMTP id k11so1994268iea.11 for ; Fri, 31 Aug 2012 13:47:25 -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:message-id:date:from:user-agent:mime-version:to :references:in-reply-to:cc:subject:x-beenthere:x-mailman-version :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:content-transfer-encoding:content-type :sender:errors-to:x-gm-message-state; bh=fS01h02iaJnAWZfDYLLke6XTeSzi1tOZEyxeU3BsYPA=; b=TD+WzD9YayXjqOEFopCej++XBC6JdDbRcrnbd/VeMuRCwb4y0R73IlQwZ917wPQzLo LPnoVaASoVYgZ8uTZ2IQrFbR8IxhxONfk75hPQ7FyiGVE1r/HqMhgXbcf97S2UTfj77J 3DvHc1vtikoyzHiYKIbksuwZgoEUJnbvsZQBTC7XOozOmg8cSk8Ut3ousunF58md5USA qPvsflUxYq04F2yA7L6n/Oklcz9sbGpJ4thwf23TBu42gME/VwgTct4yD8treQ6JuBuJ 7Bs937jIrqPcvneCE0epiv1SUtJqz/hMuWV7FNlr9SuP0BkJL+DU6fvDl/TplrMUGf85 Y/dQ== Received: by 10.50.242.3 with SMTP id wm3mr4434510igc.0.1346446045096; Fri, 31 Aug 2012 13:47:25 -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 ex8csp33532igc; Fri, 31 Aug 2012 13:47:24 -0700 (PDT) Received: by 10.204.129.23 with SMTP id m23mr4844825bks.28.1346446043009; Fri, 31 Aug 2012 13:47:23 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id ic15si5110332bkc.147.2012.08.31.13.47.18; Fri, 31 Aug 2012 13:47:22 -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 1T7Y7W-00018D-MJ; Fri, 31 Aug 2012 20:47:14 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T7Y7V-00017X-5F for linaro-mm-sig@lists.linaro.org; Fri, 31 Aug 2012 20:47:13 +0000 X-IronPort-AV: E=McAfee;i="5400,1158,6821"; a="231838834" Received: from pdmz-ns-mip.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.114.10]) by wolverine01.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 Aug 2012 13:46:55 -0700 Received: from [10.46.166.175] (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 7E36410004D5; Fri, 31 Aug 2012 13:46:55 -0700 (PDT) Message-ID: <504122BE.8080706@codeaurora.org> Date: Fri, 31 Aug 2012 13:46:54 -0700 From: Laura Abbott User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: linux-fsdevel@vger.kernel.org, Marek Szyprowski References: <503EBBD6.5080504@codeaurora.org> In-Reply-To: <503EBBD6.5080504@codeaurora.org> Cc: linaro-mm-sig@lists.linaro.org, "linux-arm-msm@vger.kernel.org" , linux-kernel@vger.kernel.org, "linux-arm-kernel@lists.infradead.org" Subject: Re: [Linaro-mm-sig] CMA page migration failure due to buffers on bh_lru 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: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQlCQhINtca8SEISC7p4eJypuuxn8ECJunnTqrcjH1bFs6g6/NbYXuoQ0vuQqcTT2yuFVlTV On 8/29/2012 6:03 PM, Laura Abbott wrote: > My quick and dirty workaround for testing is to remove the GFP_MOVABLE > flag from find_or_create_page but this seems significantly less than > optimal. Ideally, it seems like the buffers should be evicted from the > LRU when trying to drop (expand on invalid_bh_lru?) but I'm not familiar > enough with the code path to know if this is a good approach. > > Any suggestions/feedback is appreciated. Thanks. > > Laura I came up with what I think is a reasonable fix to this. Feedback is appreciated. Thanks. Laura 8<--- if (buffer_busy(bh)) 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);