Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp659329imm; Thu, 31 May 2018 07:15:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJYkccMSqxUG11vKII9cnPdY692qOXoIbN+2oIyVGDlwQ5idjJ4w9D5+nW1QepEY24E2/52 X-Received: by 2002:a17:902:42e4:: with SMTP id h91-v6mr7086937pld.27.1527776143243; Thu, 31 May 2018 07:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527776143; cv=none; d=google.com; s=arc-20160816; b=lARlAFpL2M7wPiDl2arpOs/Z8SZFARJAemtSwIvGk4gKK+FAqVxxIhHq2iDZqashse 5eLD+/nZCjunM5vAWPQpFfgI9VyAEMW4eDNL+1EqLHGyvxNIqys8T9/7fFw0DfvKKn6E W9MKRSlR3iYpMxoPK0iv/TgG6KSZoHq66BcP8bFsRo16gF4blWs61l9NTE5IPEQaUHoe kdeas5OC1wuUD5ld6ljKJcXkBW75Nymhtdw0nm3Q0Q95qotbPQ4l7x1MGz51X6Vu48BR iqKQHXxE6wLiW4AL16YRkxvBJU7h2J9d4Bc6gZN35xd2NSsnURrzIR9GLhF3RFajRFtQ 4ECQ== 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:dkim-signature:arc-authentication-results; bh=A9OzHwprljoNdB0/DmiKwkdoNQ+M4nclx118k5UijKc=; b=GubdJeXCNqwsRM1prn5hLseIWUkGy9oTP7z3Mex/zorzLdgNkPh09WrAW5NHe6aTZp eN9jbwNCSp5uUR/b9JvETylmHwHYyM8WpUSMHceQaKbUXiN0K1hYP3YombwTfKfULknb 2QUG7pbUji7CT5R9cRYu+rALvdaxFt6BJqF3w3ELW17TBCMsxebOdjQgMALRnCxLC/CO pbFl6nvDNUFBdlplrYa3tooL232qDlCvcz1Tua6DjOmN/JwKHy/Iw14V1t18Ue2SsBSt H0TFK870e3O7ld9o7imVTxWBOqBud9NEu8ze/5ztAC9WNH1UhTWH7J3v2GPFQPikSf1A pyIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=KScVOnAO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u13-v6si35710274plq.161.2018.05.31.07.15.28; Thu, 31 May 2018 07:15:43 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=KScVOnAO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755368AbeEaOO5 (ORCPT + 99 others); Thu, 31 May 2018 10:14:57 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:51320 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755093AbeEaOO4 (ORCPT ); Thu, 31 May 2018 10:14:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A9OzHwprljoNdB0/DmiKwkdoNQ+M4nclx118k5UijKc=; b=KScVOnAOyda2GPyOvqE7Vzwc6 y0k4HcGpuzDPRSGEAUxtoZdAX0Oq/VGOFks8Apo2lMkPxRkKpXuW+Erttf7z5MKHfjCjNlUR0fbdc ziGYy3f5QxamkUoGSE4Znum44/DQExMupFZOkhdava9C2sZNM946SPIrHG6JRfu++Jf23pjlHeVV+ MgWMWYIy6aW3IhOWaj2vvFlVAY71fGN34t4YYf2mbXvcBYe8Zl9aJaFqkABZm+zit3IxO+WfX9dEL tDwtdBcJ7VtO07QQ3qiMkgofqyHKthMfUvNCgY/mEZ9NFjft0Jy20etgFGbUerOvU0HwpmK3Dxw08 45gGkpihw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fOOLs-0006Tz-LG; Thu, 31 May 2018 14:14:52 +0000 Date: Thu, 31 May 2018 07:14:52 -0700 From: Matthew Wilcox To: Christopher Lameter Cc: Jia-Ju Bai , penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, linux-mm@kvack.org, Linux Kernel Mailing List Subject: Re: Can kfree() sleep at runtime? Message-ID: <20180531141452.GC30221@bombadil.infradead.org> References: <30ecafd7-ed61-907b-f924-77fc37dcc753@gmail.com> <20180531140808.GA30221@bombadil.infradead.org> <01000163b68a8026-56fb6a35-040b-4af9-8b73-eb3b4a41c595-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01000163b68a8026-56fb6a35-040b-4af9-8b73-eb3b4a41c595-000000@email.amazonses.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 31, 2018 at 02:12:00PM +0000, Christopher Lameter wrote: > On Thu, 31 May 2018, Matthew Wilcox wrote: > > > On Thu, May 31, 2018 at 09:10:07PM +0800, Jia-Ju Bai wrote: > > > I write a static analysis tool (DSAC), and it finds that kfree() can sleep. > > > > > > Here is the call path for kfree(). > > > Please look at it *from the bottom up*. > > > > > > [FUNC] alloc_pages(GFP_KERNEL) > > > arch/x86/mm/pageattr.c, 756: alloc_pages in split_large_page > > > arch/x86/mm/pageattr.c, 1283: split_large_page in __change_page_attr > > > > Here's your bug. Coming from kfree(), we can't end up in the > > split_large_page() path. __change_page_attr may be called in several > > different circumstances in which it would have to split a large page, > > but the path from kfree() is not one of them. > > Freeing a page in the page allocator also was traditionally not sleeping. > That has changed? No. "Your bug" being "The bug in your static analysis tool". It probably isn't following the data flow correctly (or deeply enough).