Received: by 10.192.165.156 with SMTP id m28csp578368imm; Wed, 11 Apr 2018 04:08:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+RXRuo+eXU5FHLzJT7PKAL49izsG9D5AI+ac+/aCIP0ih/TYjOEk5EnWKJ+66/58ki6pkO X-Received: by 2002:a17:902:525:: with SMTP id 34-v6mr4492575plf.267.1523444921106; Wed, 11 Apr 2018 04:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523444921; cv=none; d=google.com; s=arc-20160816; b=VecIFXxF7d1LQoYqhKn+1Wy7F2atYDm9DqxnLpOtPS8nA91mxX3/BpbubPayAsH3Y2 uNZ+9mrwfXjR6doSKn/1Zb7BNOJ5yPcNVut8oC6gAtLwVt0HkixtyLYIq59bXErjr8Ry qPvr8SCGcQjx/6ZqjYPJIW06y6lvpkUs1PTwTsEehXJl4hdcCuHvYmZTgTYazHWa7nm3 vX3SXeDbr/A5zK2f/qJcZoTLyNxIZ6hX1rY+QRsfABHNBsj9vmB1mLN3Diig6Kk9RbTw Qp2XJWS3lx6yFajdFFhWuqARxBpXwsECo+8qK85DbBGcRRx0ED7DwRkrHAx3Uf1DSMiO mclg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=eymdtcHdPIWPdjFIc5P9H/Qbj6gRsxG7Vv4gWHpKU9k=; b=dKMwVZ01kqr8bipND2Q0ib/UUefJu3ofNRoTaS2HbsSRro4ZR675F97FUhTBlbJmYL cgPo224YUbrllxEYdYNGsQ1FCSJp/SlZizix+36UZrTar3d51qodgvFcZ5yn8k4Pw5UD vnNNgsuUCFPwC4X5m+nQWaFnr+JqoZwzNQpaOIw/NEtRNaRcRinSbufCV6er2sbqUdXf XWDWQcYZ477565FLVba+NFZuB4OYWG72/xW5W/CW6mMktkxI6mBHA+Jap9ZtpOY9NWxt bFr+9XlmZ+V3x2K2SPpYuVYEbSybP43WdkE3nHcjCYG20384nF9Q63EGyx7o1QIZPbdH dh4Q== ARC-Authentication-Results: i=1; mx.google.com; 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 s4-v6si879407plp.266.2018.04.11.04.08.03; Wed, 11 Apr 2018 04:08:41 -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; 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 S1753149AbeDKLEX (ORCPT + 99 others); Wed, 11 Apr 2018 07:04:23 -0400 Received: from mail.windriver.com ([147.11.1.11]:32997 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbeDKLEW (ORCPT ); Wed, 11 Apr 2018 07:04:22 -0400 Received: from ALA-HCA.corp.ad.wrs.com ([147.11.189.40]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id w3BAFLwO022552 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 11 Apr 2018 03:15:21 -0700 (PDT) Received: from [128.224.155.98] (128.224.155.98) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 11 Apr 2018 03:15:20 -0700 Subject: Re: [PATCH v2] net: tipc: Replace GFP_ATOMIC with GFP_KERNEL in tipc_mon_create To: Jia-Ju Bai , , CC: , , References: <1523323053-28127-1-git-send-email-baijiaju1990@gmail.com> From: Ying Xue Message-ID: <73c0b7cb-5148-9c38-d45b-750f711b5570@windriver.com> Date: Wed, 11 Apr 2018 18:11:40 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1523323053-28127-1-git-send-email-baijiaju1990@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [128.224.155.98] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/10/2018 09:17 AM, Jia-Ju Bai wrote: > tipc_mon_create() is never called in atomic context. > > The call chain ending up at dn_route_init() is: Sorry, I don't think there is any relationship between the following call chain with dn_route_init(). > [1] tipc_mon_create() <- tipc_enable_bearer() <- tipc_nl_bearer_enable() > tipc_nl_bearer_enable() calls rtnl_lock(), which indicates this function > is not called in atomic context. > > Despite never getting called from atomic context, > tipc_mon_create() calls kzalloc() with GFP_ATOMIC, > which does not sleep for allocation. > GFP_ATOMIC is not necessary and can be replaced with GFP_KERNEL, > which can sleep and improve the possibility of sucessful allocation. s/sucessful/successful > > This is found by a static analysis tool named DCNS written by myself. > And I also manually check it. > > Signed-off-by: Jia-Ju Bai > --- > v2: > * Modify the description of GFP_ATOMIC in v1. > Thank Eric for good advice. > --- > net/tipc/monitor.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c > index 9e109bb..9714d80 100644 > --- a/net/tipc/monitor.c > +++ b/net/tipc/monitor.c > @@ -604,9 +604,9 @@ int tipc_mon_create(struct net *net, int bearer_id) > if (tn->monitors[bearer_id]) > return 0; > > - mon = kzalloc(sizeof(*mon), GFP_ATOMIC); > - self = kzalloc(sizeof(*self), GFP_ATOMIC); > - dom = kzalloc(sizeof(*dom), GFP_ATOMIC); > + mon = kzalloc(sizeof(*mon), GFP_KERNEL); > + self = kzalloc(sizeof(*self), GFP_KERNEL); > + dom = kzalloc(sizeof(*dom), GFP_KERNEL); > if (!mon || !self || !dom) { > kfree(mon); > kfree(self); >