Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4021892pxa; Sun, 9 Aug 2020 20:56:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyagClw7aFs5RrQJKJNvqCGHjWcXxG6NMiGFzYZzeWf2udyc0FfzOAY42DlWElXTpGpqIv6 X-Received: by 2002:a05:6402:b45:: with SMTP id bx5mr14291719edb.214.1597031785979; Sun, 09 Aug 2020 20:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597031785; cv=none; d=google.com; s=arc-20160816; b=DmvIvQxh98CXLQq176xdFtilE2jZOL/GQDDuNhb8M0jaCiH3it47VKeMWuY4nmf8HA j1FeOdEl4PAQP5N43ydSXH/PDiJkmfxvRq3whbE/GPRhRFncI9GW2XcJBQm8Ix9haaqw 970fiTG5Xsi523D4gzyeA7A7N1v8zVQB+fb1UMtsT2rABrT3tvRMShGFWrI240vMu5/p 2hJ+AzGsxcgGESEO0Xjwcnn+Q13sVFfzh6cQIJ8k0dom6zgLSmYmaZrToZJK8koIh+Rq KVbDxmdIbxr8QDGRUNBfudPHZuGst6YqcgTB0qnLhaPY9CnFidDiKmZg6jjMkfNw0/f6 l+zQ== 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:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=m8dS7Nf6rn9tkBRU7qRSpyG5ZLSSTsmVKgq8BTWsHS0=; b=VeuYARP1v0RtZDR9mJq9Z9GID+J+WCTyLJ9IjnWVNu7+iogxssLreGVzxHuJojemxE NA5wNnQXHTSK3k3S3DRVreznNf29+ZHwzgI3j2ct0WSHkNlH20WqA4EoKe9F/q8XZ+JY IH7aJpA7d2jmc5iQCloOjrGNB/OvAgwaitcb2UoojM1sJ7FdoLcoVYY4HwUqDOrbjmf3 vH/YE8X7Gm8iI6/BVlGQ+W1GcoKt1Lh4tvnaTnUWHSY8oLUJ/5KJPv3LIZArtkFLj9Xp kqgZtAr2vmk4tALRNNAEnj9f1/tlwCFpdSquInwiQVVzRnjmJhJsrsrqM8vMlIe9EKud Kpdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t2si9552332eji.602.2020.08.09.20.56.02; Sun, 09 Aug 2020 20:56:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgHJDy3 (ORCPT + 99 others); Sun, 9 Aug 2020 23:54:29 -0400 Received: from smtprelay0087.hostedemail.com ([216.40.44.87]:46542 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726481AbgHJDy2 (ORCPT ); Sun, 9 Aug 2020 23:54:28 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 3E759182CED2A; Mon, 10 Aug 2020 03:54:27 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:196:355:379:599:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2899:3138:3139:3140:3141:3142:3150:3353:3622:3865:3866:3867:3868:3870:3871:3873:3874:4250:4321:5007:8603:10004:10400:10848:11026:11232:11657:11658:11914:12043:12048:12296:12297:12740:12760:12895:13069:13095:13311:13357:13439:14181:14659:14721:21080:21212:21220:21324:21433:21611:21627:30054:30070:30075:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: alley78_2c011d126fd7 X-Filterd-Recvd-Size: 2562 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf16.hostedemail.com (Postfix) with ESMTPA; Mon, 10 Aug 2020 03:54:25 +0000 (UTC) Message-ID: <8cc2925b53845876475ccc4f098fbc88471d77bb.camel@perches.com> Subject: Re: [PATCH] ionic_lif: Use devm_kcalloc() in ionic_qcq_alloc() From: Joe Perches To: Shannon Nelson , Xu Wang , drivers@pensando.io, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Date: Sun, 09 Aug 2020 20:54:24 -0700 In-Reply-To: <2623670b-09f0-2ab4-d618-e478d98c186a@pensando.io> References: <20200810023807.9260-1-vulab@iscas.ac.cn> <4265227298e8d0a943ca4468a4f32222317df197.camel@perches.com> <2623670b-09f0-2ab4-d618-e478d98c186a@pensando.io> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.3-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2020-08-09 at 20:50 -0700, Shannon Nelson wrote: > On 8/9/20 8:20 PM, Joe Perches wrote: > > On Mon, 2020-08-10 at 02:38 +0000, Xu Wang wrote: > > > A multiplication for the size determination of a memory allocation > > > indicated that an array data structure should be processed. > > > Thus use the corresponding function "devm_kcalloc". > > [] > > > diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c > > [] > > > @@ -412,7 +412,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, > > > > > > new->flags = flags; > > > > > > - new->q.info = devm_kzalloc(dev, sizeof(*new->q.info) * num_descs, > > > + new->q.info = devm_kcalloc(dev, num_descs, sizeof(*new->q.info), > > > GFP_KERNEL); > > > if (!new->q.info) { > > > netdev_err(lif->netdev, "Cannot allocate queue info\n"); > > You could also remove these unnecessary allocation error messages. > > There is an existing dump_stack() on allocation failure. > > > Yes, the dump_stack() tells you which function had the allocation > failure, but since there are multiple allocation operations in this same > function, I find these helpful in knowing quickly which one of the > allocations failed, without having to track down the symbols and source > for whatever distro's kernel this might have happened in. If you do chose the message, might as well add __GFP_NOWARN to the allocation to avoid the dump_stack(). But honestly, if any allocation fails, you're OOM anyway.