Received: by 10.223.176.5 with SMTP id f5csp1229718wra; Tue, 6 Feb 2018 15:17:55 -0800 (PST) X-Google-Smtp-Source: AH8x225Ovoxuf2A3rZotwx9pgsv0wFKHXC4BpW0g4imdfyPqNJuoIdktAnAwEE9VB+2e5oruHCEX X-Received: by 2002:a17:902:8c8b:: with SMTP id t11-v6mr3864091plo.286.1517959075848; Tue, 06 Feb 2018 15:17:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517959075; cv=none; d=google.com; s=arc-20160816; b=U/76IqcJ7bkAHomeDY8hrewXblPfCBJQwHGG3BEYohc+8Uhealcsz2yK1pm4QyEZBb ppHkZTY62jlrLNA/WKFmA5pvEXMlJ56pJoiNeFSUgeVXnDuZdN4ypZ/UfGtKjZsWuS0I TOgA3G/JHaLJtTehpAn819pGMApTfuFaHGTOnAn7x/wdPCWQgqPJ/MIW95FGEPGrb+Be BUx6RGNKG9FE1mJhRVCEqCCzvHqcOMG50at0sQu1LLHC85iX2SDfcrziBOzvMFqZD/PX Av1AYWwqU0315LqSpEfB5kiqQMhM55EXYjolyUp/s21Dr8x/a0kHwPr1JTStspyqmXTZ zsvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=tfIr8T61+hfbGTq0eDctaX+f3mnYicRzfdia1HUkXOw=; b=CXwvhdgWaYFGA/Kg/gZr0zCk8Z7PAdh1GtPiozMpYtdQHZl70XHttrPzxlN4JoT4L6 W7+8gEWLGCxEdujKQwKP53sYncdFheo7BsI700aFL9GFEhp2HEu9Zo4DuTJlyZEWuNwd EckpebpA6VAG+3SOd/Ngo8tpgKk9Y8Sr659v5ZNqmMcB08ic8iV6qZLIuYg1igQ8OwHa Od20UmQVc/q0qODkmyYowBto3IQ+ovcJ5Vtrhh+tJJyo+QDgP3sgpOJZiEI2j1O68TW/ DPaDzOSC0qibwYHY20gMA1+H2/ReIqqTQwmhp2CCTiIxZUVNixdNWNdoW/f9gmWVDAFW frkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cTVsOBK9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a139si87284pfd.349.2018.02.06.15.17.38; Tue, 06 Feb 2018 15:17:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cTVsOBK9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753713AbeBFXQw (ORCPT + 99 others); Tue, 6 Feb 2018 18:16:52 -0500 Received: from mail-io0-f176.google.com ([209.85.223.176]:40833 "EHLO mail-io0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753618AbeBFXQv (ORCPT ); Tue, 6 Feb 2018 18:16:51 -0500 Received: by mail-io0-f176.google.com with SMTP id t22so4325939ioa.7 for ; Tue, 06 Feb 2018 15:16:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tfIr8T61+hfbGTq0eDctaX+f3mnYicRzfdia1HUkXOw=; b=cTVsOBK92ND2F6xPP/3p8/m/czTu6pm28zCUDcQfqcePRLAaaOY7UsAF8X+Lr6WkGs TA6SWdvq5X5dlja4gRG5Qw4geyKgfAB9zIIqHtSvUnk1lxq/UZlxFBUEpT5txoJbnuYZ k2ARWIDr2oVJwSwtwLWC0TwYPy9wxNZJi5tMMtKHz2xgOFgz9pTXoaHq2lwEwGNzQElw RutKlMFrlx3IOhDGuAxggccqZ4MKZexjsgRYriOqaEykX4eZQGUE2YBWc9Sv4+Cn/Kc8 Xhyb3+ITXGZis/yjPNhUQ5VuwuI5hCV4vBwWkk1YmIoNcrdDMx7h1hQ0ZRpp+xp3wUfL J7Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tfIr8T61+hfbGTq0eDctaX+f3mnYicRzfdia1HUkXOw=; b=sT898fjEBlal1Ki4yMOSDofyg8QJ89bY9G1q52tzJsPgZIT9S73p87V5701v6lxkfG 223T14DuCmtA5E3iKvZvaER7K3MZUIzBIdcGyBYXo87/MaFlXJNeDhlk0K4Sumqn4Zro hlTEdSYE/2TAfU1ZAyienOd7E1gokiBQ3fF5oXCyBRFzvmihA9cHFCp4MMZuYSp4p78P C9VgGSWYJX2PaHMfpldZ/ox7TyOj8IGwAq9kY23j+CZ01S67Nh5g8awAkTPCofYJqbqH IniDDhQ2JwglBa4sIlFEW2SW43VHu6VAzBm+hO59OoJ7lhE+PxawclXFc4iINbOBpXvi k7YA== X-Gm-Message-State: APf1xPDvLPZMfrHfWxaydPgiGe4lMDUiKWKyjKWw9BDskYdMttT2/BlJ pSY7MOIbQiQvTPJsTBTzQ10qRKe5skB5a72Rjl5dTA== X-Received: by 10.107.51.149 with SMTP id z143mr5118487ioz.287.1517959010276; Tue, 06 Feb 2018 15:16:50 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.172.135 with HTTP; Tue, 6 Feb 2018 15:16:49 -0800 (PST) In-Reply-To: <20180206225548.GB9680@eng-minchan1.roam.corp.google.com> References: <20180206004903.224390-1-joelaf@google.com> <20180206220159.GA9680@eng-minchan1.roam.corp.google.com> <20180206225548.GB9680@eng-minchan1.roam.corp.google.com> From: Joel Fernandes Date: Tue, 6 Feb 2018 15:16:49 -0800 Message-ID: Subject: Re: [PATCH RFC] ashmem: Fix lockdep RECLAIM_FS false positive To: Minchan Kim Cc: LKML , Peter Zilstra , Michal Hocko , "open list:MEMORY MANAGEMENT" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Minchan, On Tue, Feb 6, 2018 at 2:55 PM, Minchan Kim wrote: > On Tue, Feb 06, 2018 at 02:32:13PM -0800, Joel Fernandes wrote: [...] >> On Tue, Feb 6, 2018 at 2:01 PM, Minchan Kim wrote: >> [...] >> > On Mon, Feb 05, 2018 at 04:49:03PM -0800, Joel Fernandes wrote: >> >> During invocation of ashmem shrinker under memory pressure, ashmem >> >> calls into VFS code via vfs_fallocate. We however make sure we >> >> don't enter it if the allocation was GFP_FS to prevent looping >> >> into filesystem code. However lockdep doesn't know this and prints >> >> a lockdep splat as below. >> >> >> >> This patch fixes the issue by releasing the reclaim_fs lock after >> >> checking for GFP_FS but before calling into the VFS path, and >> >> reacquiring it after so that lockdep can continue reporting any >> >> reclaim issues later. >> > >> > At first glance, it looks reasonable. However, Couldn't we return >> > just 0 in ashmem_shrink_count when the context is under FS? >> > >> >> We're already checking if GFP_FS in ashmem_shrink_scan and bailing out >> though, did I miss something? > > I understand your concern now. Apart from that, if ashmem_shrink_count > is called under GFP_FS, you can just return 0 for removing pointless > ashmem_shrink_scan calling. But it might be trivial so up to you. :) Yes, I think we can do that in a subsequent patch since that's a different optimization. Thanks for the suggestion. >> >> The problem is not that there is a deadlock that occurs, the problem >> that even when we're not under FS, lockdep reports an issue that can't >> happen. The fix is for the lockdep false positive that occurs. > > Yub, you are right. I am happy to add > > Reviewed-by: Minchan Kim > Other than that, I thought a while we could make it in generic so we > can add SHRINKER_FS_AWARE like that so VM code itself can do for > preventing such false positive instead of doing it in each driver > itself. > > However, if driver can do by itself, it could be more flexible. Yes, off the top it feels like something that driver you should do at more finer grained level, since probably only driver knows that/if we will be looping into FS. Thanks for the review, - Joel