Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbdHCI4h (ORCPT ); Thu, 3 Aug 2017 04:56:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:35843 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751067AbdHCI4f (ORCPT ); Thu, 3 Aug 2017 04:56:35 -0400 Date: Thu, 3 Aug 2017 09:56:32 +0100 From: Mel Gorman To: Michal Hocko Cc: Paul Moore , Jeff Vander Stoep , linux-mm@kvack.org, LKML , selinux@tycho.nsa.gov Subject: Re: suspicious __GFP_NOMEMALLOC in selinux Message-ID: <20170803085547.hqpiy7qbyas7nbvy@suse.de> References: <20170802105018.GA2529@dhcp22.suse.cz> <20170803081152.GC12521@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20170803081152.GC12521@dhcp22.suse.cz> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1793 Lines: 46 On Thu, Aug 03, 2017 at 10:11:52AM +0200, Michal Hocko wrote: > > The GFP_ATOMIC|__GFP_NOMEMALLOC use in SELinux appears to be limited > > to security/selinux/avc.c, and digging a bit, I'm guessing commit > > fa1aa143ac4a copied the combination from 6290c2c43973 ("selinux: tag > > avc cache alloc as non-critical") and the avc_alloc_node() function. > > Thanks for the pointer. That makes much more sense now. Back in 2012 we > really didn't have a good way to distinguish non sleeping and atomic > with reserves allocations. > Yes, and GFP_NOWAIT is the right way to express that now. It'll still wake kswapd but it won't stall on direct reclaim and won't dip into reserves. Thanks Michal. > --- > From 6d506a75da83c0724ed399966971711f37d67411 Mon Sep 17 00:00:00 2001 > From: Michal Hocko > Date: Thu, 3 Aug 2017 10:04:20 +0200 > Subject: [PATCH] selinux: replace GFP_ATOMIC | __GFP_NOMEMALLOC with > GFP_NOWAIT > > selinux avc code uses a weird combination of gfp flags. It asks for > GFP_ATOMIC which allows access to memory reserves while it requests > to not consume memory reserves by __GFP_NOMEMALLOC. This seems to be > copying the pattern from 6290c2c43973 ("selinux: tag avc cache alloc as > non-critical"). > > Back then (before d0164adc89f6 ("mm, page_alloc: distinguish between > being unable to sleep, unwilling to sleep and avoiding waking kswapd")) > we didn't have a good way to distinguish nowait and atomic allocations > so the construct made some sense. Now we do not have to play tricks > though and GFP_NOWAIT will provide the required semantic (aka do not > sleep and do not consume any memory reserves). > > Signed-off-by: Michal Hocko Looks right to me Acked-by: Mel Gorman -- Mel Gorman SUSE Labs