From patchwork Fri Jan 26 08:48:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10185325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C6B6360383 for ; Fri, 26 Jan 2018 08:44:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5AF8290FC for ; Fri, 26 Jan 2018 08:44:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9F8229101; Fri, 26 Jan 2018 08:44:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FC63290FC for ; Fri, 26 Jan 2018 08:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752528AbeAZIoU (ORCPT ); Fri, 26 Jan 2018 03:44:20 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38947 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752336AbeAZIoT (ORCPT ); Fri, 26 Jan 2018 03:44:19 -0500 Received: by mail-pg0-f67.google.com with SMTP id w17so6858732pgv.6; Fri, 26 Jan 2018 00:44:19 -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=9UqO9+scgShf64/CCMyt2J44ubsX87xnBQaK67lAGcA=; b=Piy8pOamzaJ4qFYYUG0hJYcwe2pC+f89xkxAeFXau/S11md7KoeKx7Z5pE5eQKSXVq 88AmCSVO7FRSTockXzen0Vn8jr0Mo8nr0qV+wxJlVRuKelvrlzK9IcCANdMYR32UwXvu MBRjA9bwRnP+8U/61yZt3HV7H7daL6WJIDFq4OXgfkxnEdEj16/HLelEIeclRxooecPQ FVwz8HGPmVqUAjR0SVtBk/eY4qXAfrchi/j41ylN6SqvCBRs5wPnhTsEqFe35GTIjguG cbMEkG0Gpqom10BfVFCFW92PHz21dq+CRdroqevdEmSBuUzfCMxbpmr3L5wlxv7ugHd0 TvBQ== 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=9UqO9+scgShf64/CCMyt2J44ubsX87xnBQaK67lAGcA=; b=g3IGvLCAipuBK86YD/X7XPrEYRUCcmtERxAR0PmpxE7wgsjR2hAehigl7vArbZfVO7 +s/YcPO/TvqyOGSoGPghPA3IqeRztvzqrcLkOq999q99bWNsurFoJCqUF6GMDQdjdsoS hKBCE1Z9ycy7q8RBCd6ZacaRFdKFhYURYOL4F6Y7s7sWHgheeMT0XoY/47ajBpH3Htpz BDDVxZUE1uCRoCkg4qm2J4kYSNK3eWseOzOPKn5GHkPU5VGsTVepxPHtXD2e0L3qt+wR HoeOziEPWblplm5J5nfRUHS0m8/TffQTS3sm4a6jwpNcvLDuDy/+N+fvT4sHT+IOoWVx FSqQ== X-Gm-Message-State: AKwxytcRTsGk1K+VjgarDPXH8oNVPREx8CNs6flJBfw8LsnT6y45zGgK VZ9mrkOxNQtrezv6WZUpKKQ= X-Google-Smtp-Source: AH8x226N4OQqbWwKiaIivRgtrph0etr7X4NMi0MNQwfqzFv2RQufN4Bx6e89j6BGJK5vfEAIEUgCEw== X-Received: by 2002:a17:902:46:: with SMTP id 64-v6mr13967829pla.341.1516956259036; Fri, 26 Jan 2018 00:44:19 -0800 (PST) Received: from bai-oslab.tsinghua.edu.cn ([2402:f000:1:4413:3967:a579:e81d:66fa]) by smtp.gmail.com with ESMTPSA id e3sm18144908pfb.143.2018.01.26.00.44.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 00:44:18 -0800 (PST) From: Jia-Ju Bai To: vireshk@kernel.org, nm@ti.com, sboyd@codeaurora.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] opp: cpu: Replace GFP_ATOMIC with GFP_KERNEL in dev_pm_opp_init_cpufreq_table Date: Fri, 26 Jan 2018 16:48:49 +0800 Message-Id: <1516956529-32264-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After checking all possible call chains to dev_pm_opp_init_cpufreq_table() here, my tool finds that this function is never called in atomic context, namely never in an interrupt handler or holding a spinlock. And dev_pm_opp_init_cpufreq_table() calls dev_pm_opp_get_opp_count(), which calls mutex_lock that can sleep. It indicates that atmtcp_v_send() can call functions which may 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. Signed-off-by: Jia-Ju Bai --- drivers/opp/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/opp/cpu.c b/drivers/opp/cpu.c index 2d87bc1..0c09107 100644 --- a/drivers/opp/cpu.c +++ b/drivers/opp/cpu.c @@ -55,7 +55,7 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, if (max_opps <= 0) return max_opps ? max_opps : -ENODATA; - freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_ATOMIC); + freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_KERNEL); if (!freq_table) return -ENOMEM;