From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755410AbbBUCiA (ORCPT ); Fri, 20 Feb 2015 21:38:00 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:33874 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755269AbbBUCh7 (ORCPT ); Fri, 20 Feb 2015 21:37:59 -0500 Date: Sat, 21 Feb 2015 02:37:55 +0000 From: Al Viro To: Konstantin Khlebnikov Cc: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fs: avoid locking sb_lock in grab_super_passive() Message-ID: <20150221023754.GT29656@ZenIV.linux.org.uk> References: <20150219171934.20458.30175.stgit@buzz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150219171934.20458.30175.stgit@buzz> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 19, 2015 at 08:19:35PM +0300, Konstantin Khlebnikov wrote: > I've noticed significant locking contention in memory reclaimer around > sb_lock inside grab_super_passive(). Grab_super_passive() is called from > two places: in icache/dcache shrinkers (function super_cache_scan) and > from writeback (function __writeback_inodes_wb). Both are required for > progress in memory reclaimer. > > Also this lock isn't irq-safe. And I've seen suspicious livelock under > serious memory pressure where reclaimer was called from interrupt which > have happened right in place where sb_lock is held in normal context, > so all other cpus were stuck on that lock too. Excuse me, but this part is BS - its call is immediately preceded by if (!(sc->gfp_mask & __GFP_FS)) return SHRINK_STOP; and if we *ever* hit GFP_FS allocation from interrupt, we are really screwed. If nothing else, both prune_dcache_sb() and prune_icache_sb() can wait for all kinds of IO; you really don't want that called in an interrupt context. The same goes for writeback_sb_inodes(), while we are at it. If you ever see that in an interrupt context, you have a very bad problem on hands. Said that, not bothering with sb_lock (and ->s_count) in those two callers makes sense. Applied, with name changed to trylock_super().