Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp627217ybl; Fri, 16 Aug 2019 01:12:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9BStkEwY+phwmSSFq+upI7/ElYXz4YIz6i+tDEUc3rshS6RkKD5BUKQpxicv93a4tcBB2 X-Received: by 2002:aa7:934f:: with SMTP id 15mr9472817pfn.22.1565943171735; Fri, 16 Aug 2019 01:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565943171; cv=none; d=google.com; s=arc-20160816; b=cgBF3js5fW/YQTV3ryGXy/WtIfPn6q7TltkcmzsOpUmUeGDxylCbD0vzZ/BMzyB0O3 iNfg6CC7KzLweApVAtbJ5qfw/8B2UOj8gwyZPx3i+qryIhXombQIHOlQsL2ZR/u+82i9 Y9d30UUMKq7zqJVO4Bk/ZO1g9Y7hbPP6Ey7TDlcmE0NyKLX69A4rEovfOVIKQug9TeFe 44kj94qwhlxWAOVC8aRs2bg6t3AUEjoJ5jIJ4Yf3yIW32Y/sUw+9t09k1Z7xebpMfnga W8if3eoIrJpsRtFbVYiqr1T2Ghas09xykVlBckzabk3XxQ/moxLNevl41NZrt64GrNpn 1B1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=iH9IGordX7QDJkngMKmpFUrtrfVZgIrjziLE11+pXDw=; b=J5Gf2BlZLE0sNDi/Eqzwo/ZVGcSU8dlY9/PJ3Dazvtusy9C4WoKmL3bJdGr9yjq68Z /RcPC/paH+PPzFxXNT8+7H0IhpbsmYYExPnPbAbASN0NIih5PxrFnIH6zcGBI2PLitDg 0ugPZOfJWa34jKuRkjJrq6kIKTICMIegHFbnGUIqeFWrUWLp6LMRcrjLvMGXoSWWpopT lrLg2DfjOunsAuMbLe6300hk5UkeaVa8IsCWiFcLdcC4jORiESfhy97Zr7oBcKBwKv8L uIQbb4aRfFjoDX7JoltDjtbLY/cxQZ9UWWbuc4dU4Jj/MyzvdXKWIo5ceHpkfbOOYb/v lcSw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34si3641238pla.283.2019.08.16.01.12.33; Fri, 16 Aug 2019 01:12:51 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726991AbfHPIKe (ORCPT + 99 others); Fri, 16 Aug 2019 04:10:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:37612 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726166AbfHPIKd (ORCPT ); Fri, 16 Aug 2019 04:10:33 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 41A16AD20; Fri, 16 Aug 2019 08:10:31 +0000 (UTC) Date: Fri, 16 Aug 2019 10:10:29 +0200 From: Michal Hocko To: Jason Gunthorpe Cc: LKML , linux-mm@kvack.org, DRI Development , Intel Graphics Development , Peter Zijlstra , Ingo Molnar , Andrew Morton , David Rientjes , Christian =?iso-8859-1?Q?K=F6nig?= , =?iso-8859-1?B?Suly9G1l?= Glisse , Masahiro Yamada , Wei Wang , Andy Shevchenko , Thomas Gleixner , Jann Horn , Feng Tang , Kees Cook , Randy Dunlap , Daniel Vetter Subject: Re: [PATCH 2/5] kernel.h: Add non_block_start/end() Message-ID: <20190816081029.GA27790@dhcp22.suse.cz> References: <20190815132127.GI9477@dhcp22.suse.cz> <20190815141219.GF21596@ziepe.ca> <20190815155950.GN9477@dhcp22.suse.cz> <20190815165631.GK21596@ziepe.ca> <20190815174207.GR9477@dhcp22.suse.cz> <20190815182448.GP21596@ziepe.ca> <20190815190525.GS9477@dhcp22.suse.cz> <20190815191810.GR21596@ziepe.ca> <20190815193526.GT9477@dhcp22.suse.cz> <20190815201323.GU21596@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190815201323.GU21596@ziepe.ca> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 15-08-19 17:13:23, Jason Gunthorpe wrote: > On Thu, Aug 15, 2019 at 09:35:26PM +0200, Michal Hocko wrote: > > > > The last detail is I'm still unclear what a GFP flags a blockable > > > invalidate_range_start() should use. Is GFP_KERNEL OK? > > > > I hope I will not make this muddy again ;) > > invalidate_range_start in the blockable mode can use/depend on any sleepable > > allocation allowed in the context it is called from. > > 'in the context is is called from' is the magic phrase, as > invalidate_range_start is called while holding several different mm > related locks. I know at least write mmap_sem and i_mmap_rwsem > (write?) > > Can GFP_KERNEL be called while holding those locks? i_mmap_rwsem would be problematic because it is taken during the reclaim. > This is the question of indirect dependency on reclaim via locks you > raised earlier. > > > So in other words it is no different from any other function in the > > kernel that calls into allocator. As the API is missing gfp context > > then I hope it is not called from any restricted contexts (except > > from the oom which we have !blockable for). > > Yes, the callers are exactly my concern. > > > > Lockdep has > > > complained on that in past due to fs_reclaim - how do you know if it > > > is a false positive? > > > > I would have to see the specific lockdep splat. > > See below. I found it when trying to understand why the registration > of the mmu notififer was so oddly coded. > > The situation was: > > down_write(&mm->mmap_sem); > mm_take_all_locks(mm); > kmalloc(GFP_KERNEL); <--- lockdep warning Ugh. mm_take_all_locks :/ > I understood Daniel said he saw this directly on a recent kernel when > working with his lockdep patch? > > Checking myself, on todays kernel I see a call chain: > > shrink_all_memory > fs_reclaim_acquire(sc.gfp_mask); > [..] > do_try_to_free_pages > shrink_zones > shrink_node > shrink_node_memcg > shrink_list > shrink_active_list > page_referenced > rmap_walk > rmap_walk_file > i_mmap_lock_read > down_read(i_mmap_rwsem) > > So it is possible that the down_read() above will block on > i_mmap_rwsem being held in the caller of invalidate_range_start which > is doing kmalloc(GPF_KERNEL). > > Is this OK? The lockdep annotation says no.. It's not as per the above code patch which is easily possible because mm_take_all_locks will lock all file vmas. -- Michal Hocko SUSE Labs