Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp634412pxa; Sat, 1 Aug 2020 00:54:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq1RD0Kcm9zCGAeAUTAH70lCBHEK0NZ1JIODGfa8i5kQHuQNrBOAglCYbDHCREyopikvlh X-Received: by 2002:a17:906:7d6:: with SMTP id m22mr7307703ejc.229.1596268459877; Sat, 01 Aug 2020 00:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596268459; cv=none; d=google.com; s=arc-20160816; b=FOd75I0nAWelrdfYPQHuiTwg7xgPQYWip777BsF1C7rU5qV+uZ7uCaMrh3V33jukPz +QU0xYnDtMm7K/JQ1yhzvHpXFes34PFoc8PTWCcpH1pf/CfR+6YAXB7ps3exzm4rNSGC nZGZLqVdl78M+FcuVPvOXHAMTAeM3Bmg5GPzI2hOKBkEjjLpuZCbc8+B0fiaYn2iuNAK GaVrLzCkbgL899piH8I7AOykYw7EEJhENSgYJGomFZDsIwpQegB+cioBmnI8EoD8Q1pZ i/Jo+MdB7lp14G8TcEbnbdbFajOc4XWojkCdcMuTyRLVfD4ohL0KuXGioXwrp+XUcp6I n6mQ== 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:subject:autocrypt:from:references:cc:to; bh=D61n9PHvtCBq5d0zkEOp5P+qElAFgL6TZOSItQN+fNw=; b=iJIX/cqgnMA86KxyZqX6qqLEDgpePtqnZ829KR5BW/sTgD1Nki4pnlLv+F82Kw4KxD Z+fRlVot6viG7qBE8J9zA6EPn7ycfalPgOktjIaA782LZqLqg9B3hzqERdY1F570FHc9 p9zZt1xQm2FxA6XYtpb1aWmf/q5wokRi6vdhz63Jxv7fX8ULaukVF3whNJsrdIFPZnGD cJGFemvOFaw6pfxtFRzm5weLz7D2mtH5HAOWVSxPUyGnusA4tPEbWdfZdV+D9owEVrvu eK/Wf7OuHVF27yAA1k9hWPyCdh8qXAYSrkSh998xqF5MdS31CUKSStk0BgjkIEyU5rNz b7SA== 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 x22si3688008ejv.378.2020.08.01.00.53.24; Sat, 01 Aug 2020 00:54:19 -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 S1728255AbgHAHvq (ORCPT + 99 others); Sat, 1 Aug 2020 03:51:46 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:33796 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbgHAHvp (ORCPT ); Sat, 1 Aug 2020 03:51:45 -0400 Received: by mail-lf1-f68.google.com with SMTP id d2so12370360lfj.1; Sat, 01 Aug 2020 00:51:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=D61n9PHvtCBq5d0zkEOp5P+qElAFgL6TZOSItQN+fNw=; b=unv+3hObHZgB8yP54vrmdlrM5+vvC/+ZSqriaEhK5XwdL1PHyi/b/EHxLpS4kKSKsH UgExMTZIHOICVh78QwCh+nrKWyQAtXhZqciPFsQohnaaRL9Qf4zNW8ldfKIuCvbIS+fn Gki8Q8p3/vLgCDSqxMDvsYrfK5d9VevRKgYQuywiZLqGpXhBykrz5Hz+znPanHrz5faR O0zFSRLF3uHUbhtHvq3Z+6rU3SfZv81aq+z9bs9oZ44rznM0i3PhhzXm+CtIJGamrEu+ +bL1dBFj30W4nwbQ3hJyFa3j6E0eNmoQ8YvzR9HaUkFbWQ/1PU2Vw83MoVrGDa2VUfMb 0jTg== X-Gm-Message-State: AOAM530KuTlQhykItj1h7RihGdN8U8OFdSvwUKbyTBLULou5aZHr0Y9J QymElmSvh9Xodzh2VIXX31B4uB9p1QI= X-Received: by 2002:ac2:4d31:: with SMTP id h17mr3695345lfk.144.1596268301922; Sat, 01 Aug 2020 00:51:41 -0700 (PDT) Received: from [10.68.32.192] (broadband-37-110-38-130.ip.moscow.rt.ru. [37.110.38.130]) by smtp.gmail.com with ESMTPSA id t22sm2515675lfr.12.2020.08.01.00.51.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 01 Aug 2020 00:51:41 -0700 (PDT) To: Joe Perches , "Martin K. Petersen" , "James E.J. Bottomley" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200731215524.14295-1-efremov@linux.com> <33d943d2b83f17371df09b5962c856ea2d894954.camel@perches.com> <70fb8220-2102-adb5-bbe6-9c2ea74a0623@linux.com> <8638183f559c0f8f8d377bd0a6c91903b2c588df.camel@perches.com> From: Denis Efremov Autocrypt: addr=efremov@linux.com; keydata= mQINBFsJUXwBEADDnzbOGE/X5ZdHqpK/kNmR7AY39b/rR+2Wm/VbQHV+jpGk8ZL07iOWnVe1 ZInSp3Ze+scB4ZK+y48z0YDvKUU3L85Nb31UASB2bgWIV+8tmW4kV8a2PosqIc4wp4/Qa2A/ Ip6q+bWurxOOjyJkfzt51p6Th4FTUsuoxINKRMjHrs/0y5oEc7Wt/1qk2ljmnSocg3fMxo8+ y6IxmXt5tYvt+FfBqx/1XwXuOSd0WOku+/jscYmBPwyrLdk/pMSnnld6a2Fp1zxWIKz+4VJ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OGOLLMe7v zod9dwxYdGXnNRlW+YOCdFNVPMvPDr08zgzXaZ2+QJjp44HSyzxgONmHAroFcqCFUlfAqUDO T30gV5bQ8BHqvfWyEhJT+CS3JJyP8BmmSgPa0Adlp6Do+pRsOO1YNNO78SYABhMi3fEa7X37 WxL31TrNCPnIauTgZtf/KCFQJpKaakC3ffEkPhyTjEl7oOE9xccNjccZraadi+2uHV0ULA1m ycHhb817A03n1I00QwLf2wOkckdqTqRbFFI/ik69hF9hemK/BmAHpShI+z1JsYT9cSs8D7wb aF/jQVy4URensgAPkgXsRiboqOj/rTz9F5mpd/gPU/IOUPFEMoo4TInt/+dEVECHioU3RRrW EahrGMfRngbdp/mKs9aBR56ECMfFFUPyI3VJsNbgpcIJjV/0N+JdJKQpJ/4uQ2zNm0wH/RU8 CRJvEwtKemX6fp/zLI36Gvz8zJIjSBIEqCb7vdgvWarksrhmi6/Jay5zRZ03+k6YwiqgX8t7 ANwvYa1h1dQ36OiTqm1cIxRCGl4wrypOVGx3OjCar7sBLD+NkwO4RaqFvdv0xuuy4x01VnOF Subject: Re: [PATCH] scsi: libcxgbi: use kvzalloc instead of opencoded kzalloc/vzalloc Message-ID: Date: Sat, 1 Aug 2020 10:51:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8638183f559c0f8f8d377bd0a6c91903b2c588df.camel@perches.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/1/20 1:24 AM, Joe Perches wrote: > On Sat, 2020-08-01 at 01:10 +0300, Denis Efremov wrote: >> >> On 8/1/20 12:58 AM, Joe Perches wrote: >>> On Sat, 2020-08-01 at 00:55 +0300, Denis Efremov wrote: >>>> Remove cxgbi_alloc_big_mem(), cxgbi_free_big_mem() functions >>>> and use kvzalloc/kvfree instead. >>> >>> Sensible, thanks. >>> >>>> diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c >>> [] >>>> @@ -77,9 +77,9 @@ int cxgbi_device_portmap_create(struct cxgbi_device *cdev, unsigned int base, >>>> { >>>> struct cxgbi_ports_map *pmap = &cdev->pmap; >>>> >>>> - pmap->port_csk = cxgbi_alloc_big_mem(max_conn * >>>> - sizeof(struct cxgbi_sock *), >>>> - GFP_KERNEL); >>>> + pmap->port_csk = kvzalloc(array_size(max_conn, >>>> + sizeof(struct cxgbi_sock *)), >>>> + GFP_KERNEL); >>> >>> missing __GFP_NOWARN >>> >> >> kvmalloc_node adds __GFP_NOWARN internally to kmalloc call >> https://elixir.bootlin.com/linux/v5.8-rc4/source/mm/util.c#L568 > > Only when there's a fallback, and the fallback does not. > Sorry, Joe, I don't understand why do we need to add __GFP_NOWARN here. We use GFP_KERNEL for allocation. cxgbi_alloc_big_mem adds __GFP_NOWARN only to kzalloc(). kvzalloc is: kvmalloc(size, flags | __GFP_ZERO) kvmalloc is: kvmalloc_node(size, flags, NUMA_NO_NODE) kvmalloc_node: if ((flags & GFP_KERNEL) != GFP_KERNEL) // false, flags == GFP_KERNEL|__GFP_ZERO return kmalloc_node(size, flags, node); if (size > PAGE_SIZE) { kmalloc_flags |= __GFP_NOWARN; // add __GFP_NOWARN for "big" allocations if (!(kmalloc_flags & __GFP_RETRY_MAYFAIL)) kmalloc_flags |= __GFP_NORETRY; } // kmalloc_flags == GFP_KERNEL|__GFP_ZERO|__GFP_NOWARN if size > PAGE_SIZE ret = kmalloc_node(size, kmalloc_flags, node); if (ret || size <= PAGE_SIZE) return ret; // flags == GFP_KERNEL|__GFP_ZERO return __vmalloc_node(size, 1, flags, node, __builtin_return_address(0)); So, to my understanding the difference is only that cxgbi_alloc_big_mem adds __GFP_NOWARN to kzalloc unconditionally, kvzalloc adds __GFP_NOWARN to kmalloc_node if size > PAGE_SIZE. We use: max_conn * sizeof(struct cxgbi_sock *) in allocation. max_conn can be either CXGBI_MAX_CONN or CXGB4I_MAX_CONN. CXGBI_MAX_CONN == 16384, CXGB4I_MAX_CONN == 16384. Thus the allocation is bigger than PAGE_SIZE and kvmalloc_node adds __GFP_NOWARN to the kmalloc_node call. Maybe I missed something? Thanks, Denis