Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1305315imm; Mon, 9 Jul 2018 22:40:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdpMjsPG++zg0gaG4uMJbsJryBWtaG2DRKe7+ifl8KBDCArQ75aJLB3uPW39eASks5m998h X-Received: by 2002:a62:b90f:: with SMTP id z15-v6mr24475750pfe.254.1531201249318; Mon, 09 Jul 2018 22:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531201249; cv=none; d=google.com; s=arc-20160816; b=nD+2ApS8GQOs+WChbqfcF0Ih/+7o2skvLcRdzM8akYDgz0K+CBSD7xJhxqj+f7F0Mr vJg/jGq27bdoh67da29VXggFeAQbsQ4vQx77D7dHc5zWg9XCQ8XXu2/j1OTmxqFvbjFE JQfj/ociiaWW1s8O6lfm+5HIVJDLRDXkOkrA1dlCBcwOAlCzJ4ce3yIk8w7O38hBFd7m hGhpEOcgwIdZHwokHNcupfh6TfZ5Tc4InsYOfTuNlmFcmym3HPcTDS2Qya7TSJxoybm+ zhjkiPvOLpLwOMgChqW19t+1xmHnuw9KhpjmCs9wC7ah/WBV4JdvItlaPdNBzbvc9ShY /Nzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=kFOw3hq5neCrT8hz5YN5kOZiTr2mEb58qkPkkfGCqq0=; b=mE8SjF8ODmWi+UPkngUIhkw/HE09hoRSUtrinzlNJ2ssgm7mime6Gu3KvES410S+6t hUqz5KgMYCaybL3MaUiX8yIjxaa67eM47WWUfwFZi6b6XtCqQbJ/bj9s5PPg24wUZwsw pvyq97QZU/08FsIoPpRb0dV+YKMZOkhUZJwYKLg5xSney3Ub6dCwbCSfcUxnwOSiCegQ q+70Snv5BwhfYNd7nlLQPPyUMkCv0ukoFnXBdUz5NoKnP4aOepsvUm3YrQwJzZKEWtTW djoPwbh2LcGk4SXtyoeRxbvQp2Ki50cuaMIOYi+y3x87oL1QcLZbslRF7Kc1kpa/ziVj mweA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=STmHNsRk; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 59-v6si16138227plc.30.2018.07.09.22.40.32; Mon, 09 Jul 2018 22:40:49 -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; dkim=pass header.i=@kernel.org header.s=default header.b=STmHNsRk; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751104AbeGJFju (ORCPT + 99 others); Tue, 10 Jul 2018 01:39:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:35552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbeGJFjs (ORCPT ); Tue, 10 Jul 2018 01:39:48 -0400 Received: from localhost (unknown [193.47.165.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 62A0320873; Tue, 10 Jul 2018 05:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1531201188; bh=+L9biaam00i/5fDTM7YvKSjAvJakID01EfO8ZcCpgSk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=STmHNsRkZSA5OshD4crYYz/+tD4/fQZGeYN1Zwa47KehDag34saJPkHK+3+POzPeA YXSJJKwwW2rPQPrzKrPsbPRE5UFeFgwBAm3KdB27UmCJ0LzGvW1vNnPYUcvfyKjNdp /OIu02pzCNVL9Ldz1wD1JAcoQyIrQlQKTmSaBRyc= Date: Tue, 10 Jul 2018 08:39:44 +0300 From: Leon Romanovsky To: Jan Dakinevich Cc: Doug Ledford , Jason Gunthorpe , Bart Van Assche , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Denis Lunev , Konstantin Khorenko Subject: Re: [PATCH] ib_srpt: use kvmalloc to allocate ring pointers Message-ID: <20180710053944.GN3014@mtr-leonro.mtl.com> References: <1531144268-25361-1-git-send-email-jan.dakinevich@virtuozzo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0OOz7ZB592LYQf07" Content-Disposition: inline In-Reply-To: <1531144268-25361-1-git-send-email-jan.dakinevich@virtuozzo.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0OOz7ZB592LYQf07 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 09, 2018 at 04:51:08PM +0300, Jan Dakinevich wrote: > An array of pointers to SRPT contexts in ib_device is over 30KiB even > in default case, in which an amount of contexts is 4095. The patch > is intended to weed out large contigous allocation for non-DMA memory. kvmalloc* doesn't "weed out" large contiguous allocations, but tries to allocate them and gracefully fallback to vmalloc if kmalloc fails. More on that, for allocations less than page (64KB for PowerPC), it will not call to vmalloc at all, which is fine too, because pages granularity. If you want to get rid of "contiguous allocations", use vmalloc instead. Thanks > > Signed-off-by: Jan Dakinevich > --- > drivers/infiniband/ulp/srpt/ib_srpt.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c > index 3081c62..de167af 100644 > --- a/drivers/infiniband/ulp/srpt/ib_srpt.c > +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c > @@ -720,7 +720,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev, > WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx) > && ioctx_size != sizeof(struct srpt_send_ioctx)); > > - ring = kmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL); > + ring = kvmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL); > if (!ring) > goto out; > for (i = 0; i < ring_size; ++i) { > @@ -734,7 +734,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev, > err: > while (--i >= 0) > srpt_free_ioctx(sdev, ring[i], dma_size, dir); > - kfree(ring); > + kvfree(ring); > ring = NULL; > out: > return ring; > @@ -759,7 +759,7 @@ static void srpt_free_ioctx_ring(struct srpt_ioctx **ioctx_ring, > > for (i = 0; i < ring_size; ++i) > srpt_free_ioctx(sdev, ioctx_ring[i], dma_size, dir); > - kfree(ioctx_ring); > + kvfree(ioctx_ring); > } > > /** > -- > 2.1.4 > --0OOz7ZB592LYQf07 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJbREagAAoJEORje4g2clinc8MP/jEJQeruV+X+Af8kW/TU/Jps GF1fuPUL+XTh47Zr6BHbCAspjcHn853TS43o4IQOJFMaCWHfkxBAxx0Qf9dm/FfR xrwFmtBdOu5nvMfNG6LAQ9j1RmpsAi+wSii3xZJRgwM3uc7kYHYlkmm+y6fGALKL ceQS9bhhI1m9CHTR+u61p5hTesxr3s8fY2mUoYh6vmCEh2RWgPMvUF9U/Gq5u3br D9GAhYXd63K2OxIS1C1K9I6+5h6rpFuar/jQgrC1yrWqfOvalnjZCytiIEX1Mz2E T2urRf6v/h5RZFCHGkm/ke0XIug9Vig/T58d1Byj6h7tBtwq+kXiue2EHCIKh1UT D4T1EbwP24i+64SzYcABz5eLMIATLp6vgEtbP9HeS5HykgE01ct+4d6RT0r0V1Fe MyDTpg7Kl3sU4nTF4EV8ZAnG9EvRcu2ZIjb0YqDQ1BbGmPTUjUrZvfU9o8f75Pyf qlitI0cig2N2QzfCY12wkDP/SxEBRGaOXaAVhNvnthIQ2uHjBWvRf4lL3dK99qz2 bq8/mF+SQBqnTHVAI+3Xxh8GQahEDk6T1+nkpa6U7PMaQNEZTqC28IKN5TefI0nD GpguPEmBraFCxdeHfVRKPf7pGKrmlAVXp4txyBTEf28vFlt0XhvUD3ZMgCsd9pu2 YMviGhO3eGg28Gnw53Mb =Z3p4 -----END PGP SIGNATURE----- --0OOz7ZB592LYQf07--