Received: by 10.223.176.46 with SMTP id f43csp914014wra; Fri, 26 Jan 2018 08:50:54 -0800 (PST) X-Google-Smtp-Source: AH8x224UL0sVc2wsvEbl1LnPuyVSgEg1ci1tE6j6BSZLi8edKSVSmyyp2abEcX3Ajo3gow7dWIhe X-Received: by 2002:a17:902:1682:: with SMTP id h2-v6mr14499532plh.116.1516985454089; Fri, 26 Jan 2018 08:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516985454; cv=none; d=google.com; s=arc-20160816; b=L/QtdaaQvUhoj/paTnOr/Z6zGiI2N4T3ZEaowCfMaiIYQMZZ4Nxq5KkCFKLLhwNo9q hg5077x4krpUxDB0KdWDqdywL2GFMY4gEWRqPtJjcZWMBzUHu9JMVbDvjnxkYiKWDbzK A3ulzt/6ny8y+Eq0L5mJRSOU6T5NReqrUY5/dsxecnctj5CfVEMcRZgaLX7q87znFH96 3Ho4f028POqkc4QFv/k/3lUamOHuMt85BkdfX2kbu1vq5QRD/DteN4TGBq+riHCcAzyL WAbnWfAcntjnz6GJDFeOowscstHN1BJESYcp3z23xwA+YZCo8p6BULkMgWJGQf6iYaop BxYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=EPzUkwGcjm6bEbAyUhySAzYlvypYu7WvTjGpqVaXuLo=; b=fturMkAbP5UFiiQb1HQs1IcaehTyrjrfq1z/WcUTQwbM5skif0TWFacUnlMAVfJH2D Kgjz78OfeOk/qLEOWzeN1PpZtkIFNtJiLTnAPSWvY23eYQcHTHdn5Dj7Ow8Nk0MKiVdN 1NOqoG0Ars7GKcw23Ly6/TXkhi58tIQqWc+zMyGhJabPUdzFM/F+6RMpSq5gAgOIW3B0 L529C+MwrqsyRYfgnIV+THNEWulto3IlM0O7lET48Cis7uPA4mORXYeuT7L1SUejWsSa YmSo0MIJCv/mswMwogSvtsM1IzcLEuN4ig5vuPdeJyqK/Nld1xr9MoBEEOJlr9Z910SA /LBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u4HEacG1; 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=NONE 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 u74si3210432pgc.445.2018.01.26.08.50.39; Fri, 26 Jan 2018 08:50:54 -0800 (PST) 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=u4HEacG1; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751374AbeAZQuG (ORCPT + 99 others); Fri, 26 Jan 2018 11:50:06 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:42074 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751072AbeAZQuF (ORCPT ); Fri, 26 Jan 2018 11:50:05 -0500 Received: by mail-pf0-f194.google.com with SMTP id b25so612267pfd.9 for ; Fri, 26 Jan 2018 08:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=EPzUkwGcjm6bEbAyUhySAzYlvypYu7WvTjGpqVaXuLo=; b=u4HEacG1z8YdI2PcEpC2noMYYKvit4etiUZ9VBBT40UAiKBktBxVC/h5UsHWGvckjx AHzUlji5bes8bix1JmEoh0G7yDE7TLeeDLvhTe3A4m82DILS9yGKdo4WAxyzNn1XIanA WIIw+xx+nEdLtLJ/dTsVdLrDLRBTj52bBcc5lGg94IAeBHF3agkdIcE8iaveZX530mOO 3/kggJLx9bZUVa1iKFcZIwvtF0SaI8Xk0ZYx/IHTl8L83uoHg27rMNJMnY51l7oaxtNC h2aRLVqnUFVebwwQDsau5mAmHcsyhy1RxROsZeR30+wF6XGZFO7K9pjM2IdC98FeO8o9 0vAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EPzUkwGcjm6bEbAyUhySAzYlvypYu7WvTjGpqVaXuLo=; b=NVuaIgyZAg5RM+ekI10BujYsA3edWeBKg6nJawLTgX2z+LFCbCwBwNXjy8ZUIw56Ex QxrnXdQJAzqPnFTjEBfh9lnMc+RM+QOTmmXHb4F0n4FCCK1qkWYNsHETXHInEBAaqwZi D//Db/S+gQAktJa2RkgWVzHO4uOv26C398p09DvW5Q3kg+h7CTN9oBqQ9w6TgZUaBWcU 779LO6jSwkRFiUarTAtSRNtbLitwefui01JinZtyeykuu1TGUrlb6f7hENF7noEmC2SX 1KlJOyjqjRHpZkmYnyi91haI78skNW8GEij6OUXCYd70pWAFIa93+t50Sb1Dbb0T00aB U0lA== X-Gm-Message-State: AKwxytcKEg1NXLOiS/WgG6/rGVJgvf6s2RlRB7BQSM9x/wL0p8Gfi+TG 0gSZajod7j2ZHDIYO43N54g= X-Received: by 10.98.32.93 with SMTP id g90mr6883632pfg.17.1516985404576; Fri, 26 Jan 2018 08:50:04 -0800 (PST) Received: from bai-oslab.tsinghua.edu.cn ([2402:f000:1:4413:3967:a579:e81d:66fa]) by smtp.gmail.com with ESMTPSA id w27sm8803731pge.54.2018.01.26.08.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 08:50:04 -0800 (PST) From: Jia-Ju Bai To: bernhard.walle@gmx.de Cc: linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] firmware: memmap: Replace GFP_ATOMIC with GFP_KERNEL in firmware_map_add_hotplug Date: Sat, 27 Jan 2018 00:54:40 +0800 Message-Id: <1516985680-9575-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After checking all possible call chains to firmware_map_add_hotplug(), my tool finds that this function is never called in atomic context, namely never in an interrupt handler or holding a spinlock. I manually check the code, and find that this function is only called by add_memory_resource() that calls mem_hotplug_begin(), and mem_hotplug_begin() calls mutex_lock() that can sleep, so it indicates that firmware_map_add_hotplug() can call function which can sleep. Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL. This is found by a static analysis tool named DCNS written by myself. And I also manually audit the result. Signed-off-by: Jia-Ju Bai --- drivers/firmware/memmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c index 5de3ed2..598eb05 100644 --- a/drivers/firmware/memmap.c +++ b/drivers/firmware/memmap.c @@ -297,7 +297,7 @@ int __meminit firmware_map_add_hotplug(u64 start, u64 end, const char *type) entry = firmware_map_find_entry_bootmem(start, end - 1, type); if (!entry) { - entry = kzalloc(sizeof(struct firmware_map_entry), GFP_ATOMIC); + entry = kzalloc(sizeof(struct firmware_map_entry), GFP_KERNEL); if (!entry) return -ENOMEM; } else { -- 1.7.9.5