Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp51668imm; Thu, 31 May 2018 18:19:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIoWfOnpo1LW92tAKS/wAA230p1rs0r0gwbe7fqStwkXgR/x+RRqJ9D5fCNFipWBsoxIEtB X-Received: by 2002:a17:902:8f93:: with SMTP id z19-v6mr9000151plo.166.1527815990651; Thu, 31 May 2018 18:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527815990; cv=none; d=google.com; s=arc-20160816; b=GkqgL9BKCSxNM8bVaLwylGfr3csVNtLD/fapn/tn3VrjXqbUab6dH5omurku8vk5qu q+0ULQ/5sOLwVQVRrPjtXy4hs9m9DEgZBHs/DCqKFMOOfAPwHFHdIB3PzUMXkpXKdcvi r4unXd4SOf1AdVVf1lPQWi9IuboA9k9MIRq9gnaeZg5LZzqhlVOfG/X8Elzc+Y47hxLo WcFlsCJ12DeZrOHM8OL3X2Dus5JhiV96ZjCeDsy3gh0mnyOY3jQtRJrbCwncJakd+FDv EUJryP76mPiuLR+B/MhGIPftCh7YzWGMNOUd7QNyViaMyjc6S2HNIrX5GQrQWbtPqZk7 FlwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Qo+oPm/1xDOVvHW4x4KnXihK/UQ4+qJ3pg0+T6sdUVI=; b=An/R68bo2PzFP+INSWC7XN03w3N4mFxtEfHC5TdmATtO9lKLZ/h9YGDmMRDCuevosl x6aIot6OBN6PiCXGOBqE7SFQ+zuRLxQ+/MXyQ2tgbO6/DFx6o6Y+V6hrfSX7M3zUH+rG iQ1JHOamg3Y/ZYtJQ6a0CVcfs38CgqdAYooT5QkWVkAqxBP32+Yv0o9BezQYyxf1zARv H+M5k0xQN+1ocTcrgD+psg6lKyuZcfXR5jP2AlFhRY0PTVdj5OTdgjud7WTxQtrvhNSG +hixEjlw9t8w3bVjGX93mxUopHch/Z5wJo4qOxl5zM19KLKFoGwxZbH4MKBUPFEo+70l RIBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VPjBaKg1; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68-v6si13821709pga.324.2018.05.31.18.19.34; Thu, 31 May 2018 18:19:50 -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=@gmail.com header.s=20161025 header.b=VPjBaKg1; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750983AbeFABTI (ORCPT + 99 others); Thu, 31 May 2018 21:19:08 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:40182 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbeFABTH (ORCPT ); Thu, 31 May 2018 21:19:07 -0400 Received: by mail-pg0-f67.google.com with SMTP id l2-v6so10478249pgc.7 for ; Thu, 31 May 2018 18:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=Qo+oPm/1xDOVvHW4x4KnXihK/UQ4+qJ3pg0+T6sdUVI=; b=VPjBaKg1UMIpP5GDGaXsJA9fwKxdSuAxAzc9piYseGOI+JELVyTKwumvRizwCRSITF 3EemYWXoCNi+8S9bbPZEhIVmHswondWEssGxvKjJqZb8jDqrnfZX8t7SVCsoULjZJiMi OC4XsieQLnPoOWNLtVuBA07WGWSRm/w+efMDNDdCn0OcTwudwCWgtGOwAjoYAu6mtGWm xoy3PD8aGVMmEZ3ma4dXIm9JnfIqdRxy7smWB/flG9qyxKe0rEvr//H5rBXtWEJldwKp FpAwDM4mJEEtmuU6MoThCETSgcA2elGd4Ph691mjHP0bovIqUecduKwj2H1zR7JneONj NR6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Qo+oPm/1xDOVvHW4x4KnXihK/UQ4+qJ3pg0+T6sdUVI=; b=Dqx101ODiaF9fYFPNd3MxJiPTQF/BRb2LghPmVCCzzcI/7ijVSRW+rS4eq8KcUikow pZzHOjx6lEY2go30WWHX03SAIbuxoM8t4EHfoy3HQ5wNykyEd6POxOSxHwuY+hdwBazU xW33KIDeoGCsDRpuiq7/xrZwhlNttITLda6FWxmgZmz9n/vMnQ+6ClWs/JmVfizsYhiB JmIW6jc5Fb6XdQ8Vp6GrmUB6Cty4VMHN9XfAm8vWmwAIwmH1JuE+Fqt7aTIuO5Lk/AG+ dgb/q1YCRlZavbDUx4nFN9NldAfap01qWG/fqvjmCnSoRtajIaM7tUgKk3/PpgV+eY4O FYow== X-Gm-Message-State: ALKqPwe4o7DTag8EL7YdK/ndRL/gg9HPRV69nDk4SlvqtlL8R8K2HPqR MSYOzAjfGW79k3wMuaiLrQqitOgZ X-Received: by 2002:a63:5f12:: with SMTP id t18-v6mr6995918pgb.81.1527815946653; Thu, 31 May 2018 18:19:06 -0700 (PDT) Received: from ?IPv6:2402:f000:1:1501:200:5efe:166.111.70.46? ([2402:f000:1:1501:200:5efe:a66f:462e]) by smtp.gmail.com with ESMTPSA id v26-v6sm5239120pfe.13.2018.05.31.18.19.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 18:19:06 -0700 (PDT) Subject: Re: Can kfree() sleep at runtime? To: Christopher Lameter Cc: Pekka Enberg , David Rientjes , Joonsoo Kim , akpm@linux-foundation.org, linux-mm@kvack.org, Mel Gorman , Linux Kernel Mailing List References: <30ecafd7-ed61-907b-f924-77fc37dcc753@gmail.com> <01000163b6883743-79e003fa-71c2-4e9d-aa4a-35fcd08bb0d8-000000@email.amazonses.com> From: Jia-Ju Bai Message-ID: <3b65993d-9e96-4354-8761-ae1f87c5ae20@gmail.com> Date: Fri, 1 Jun 2018 09:18:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <01000163b6883743-79e003fa-71c2-4e9d-aa4a-35fcd08bb0d8-000000@email.amazonses.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/5/31 22:09, Christopher Lameter wrote: > 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? Thanks for reply :) I am also confused about it. I get in here according to the definition of free_pages_prepare(): 1022. static bool free_pages_prepare(...) { ... 1072. arch_free_page(page, order); 1073. kernel_poison_pages(page, 1 << order, 0); 1074. kernel_map_pages(page, 1 << order, 0); // *Here* 1075. kasan_free_pages(page, order); 1076. 1077. return true; 1078. } Best wishes, Jia-Ju Bai