Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp653299imm; Thu, 31 May 2018 07:10:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKWqmSOmufIBuwnN3U7TEWsByRPiexAkD/ANVzC44NTGZ6ZQd4tWie9cbzBCf72FZbkh6d7 X-Received: by 2002:a62:a21e:: with SMTP id m30-v6mr7034725pff.251.1527775809970; Thu, 31 May 2018 07:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527775809; cv=none; d=google.com; s=arc-20160816; b=F3RaV9VuOE+X+DqcydS3L0ddr9IefrWDCKGrCkI0bNkMLOew24YUkCOJcjecTk/33W MHnPwEmVIfUxqXMhbugCuyaifUziBswJ0wk0LCjWG6d6V2ipeQmtMudINtr80ka+y9bO 6Jf4aOmBxiIPHayb9zlb+/KQV75/0s/ZGw/Bkz2chVrbC3ePWM0/tFtw5btVjUhLtwUw 4ipVDasXHazzoLOv/SRAazU19kBbUlX02pzppYdhlfgTwtt6eHxdTucxmR7Qs5qudWuF mbHelmFNBiSkrW2EaB31Llc+qfGv0ArHlieAuy+mObuqqGfutdfA0dt6zW1pVST/HoPj RvDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=Rx/kmR/Y3xAcEH8ndJUG25zXd4fHTQe4uCK5Gj7ECYM=; b=sB8+8naODW49hRzhCvlpqIpmaXHiQ3hblB6vB2OLy8UVOHtl0GpHpM2GWgKIaUOnGt /6AoF8DTB+6HL6ivEi0lWKVmVdGxuCIa6Ru27pRu8XIJ1lkfjN9KHsil4gLz3oG2red/ oRrKbDQBD4/1oot5JySokSqRZ4e9TSKVENrSVMbF4cHfazbixCgQxiM2aPx+5H9FmkNQ +L1b4z8FOGHrVclDu4Ioay3+y5ZgQt8zCCocG04kL/2w0S32G6ZVMCNnk3XJDOMzzCQB XvHDs9Yej4blquGP69GN0OuZuK4Ev643g+ZhP20l7bE7Ry2Ea4mW8Kv8OaOq681D1U2g eMoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=WVeN9Xh5; 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 l36-v6si4907771plg.248.2018.05.31.07.09.55; Thu, 31 May 2018 07:10:09 -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=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=WVeN9Xh5; 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 S1755310AbeEaOJd (ORCPT + 99 others); Thu, 31 May 2018 10:09:33 -0400 Received: from a9-99.smtp-out.amazonses.com ([54.240.9.99]:43768 "EHLO a9-99.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755093AbeEaOJc (ORCPT ); Thu, 31 May 2018 10:09:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1527775770; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=Rx/kmR/Y3xAcEH8ndJUG25zXd4fHTQe4uCK5Gj7ECYM=; b=WVeN9Xh5cLPo705DvSlTIX3yMNj0foCGYfQDIgQC0jwgq/5LViXJvwRAmgCi6Hih jYCkfaRjv0EzHX8XgD5lzaouSnG0J6JFSiTkj2kCc6KaUMp1pOHAVO+jr1U8tAJIK9L gfIy3a7DcEs4BQU6EsQ1D4i5t4APGCBXZMtfuLwY= Date: Thu, 31 May 2018 14:09:30 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Jia-Ju Bai cc: Pekka Enberg , David Rientjes , Joonsoo Kim , akpm@linux-foundation.org, linux-mm@kvack.org, Mel Gorman , Linux Kernel Mailing List Subject: Re: Can kfree() sleep at runtime? In-Reply-To: <30ecafd7-ed61-907b-f924-77fc37dcc753@gmail.com> Message-ID: <01000163b6883743-79e003fa-71c2-4e9d-aa4a-35fcd08bb0d8-000000@email.amazonses.com> References: <30ecafd7-ed61-907b-f924-77fc37dcc753@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2018.05.31-54.240.9.99 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 31 May 2018, Jia-Ju Bai wrote: > I write a static analysis tool (DSAC), and it finds that kfree() can sleep. That should not happen. > 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 > arch/x86/mm/pageattr.c, 1391: __change_page_attr in __change_page_attr_set_clr > arch/x86/mm/pageattr.c, 2014: __change_page_attr_set_clr in __set_pages_np > arch/x86/mm/pageattr.c, 2034: __set_pages_np in __kernel_map_pages > ./include/linux/mm.h, 2488: __kernel_map_pages in kernel_map_pages > mm/page_alloc.c, 1074: kernel_map_pages in free_pages_prepare mapping pages in the page allocator can cause allocations?? How did that get in there? > mm/page_alloc.c, 1264: free_pages_prepare in __free_pages_ok > mm/page_alloc.c, 4312: __free_pages_ok in __free_pages > mm/slub.c, 3914: __free_pages in kfree > > I always have an impression that kfree() never sleeps, so I feel confused > here. Correct.