Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4536763imw; Tue, 12 Jul 2022 09:35:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v5Tf1S3OFjLVm8j9GZS4YRy1nCbVVOrgLS23TGg9/n9HM/Z5GaYmaOHYcVcd1dJ4Qguq0d X-Received: by 2002:a05:6402:11c9:b0:43a:b054:52ba with SMTP id j9-20020a05640211c900b0043ab05452bamr31128120edw.344.1657643743257; Tue, 12 Jul 2022 09:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657643743; cv=none; d=google.com; s=arc-20160816; b=mbt5Xm2k05hQL/y3j85hcMLifEEiJhhEfkoilanoiVRnsRkjn6GZK6Mt9QpY5MJJWU ye8fYjMkLcqgX+d9gJZIBwPFnsIcrENgnbHjgN0P0TJuUgfyYumtKlo2t17CgXZNQTQ9 Qn3WKrOlzwMMifWYU2RRvy1mGneuWUihr/5u9WeaOqlh/oRle1qBahhvAZbjYna++jXC 16wttxRrorUvBU9EB/fOqxZSk1eNy0sxwI3sKePTIB0AWAyqlGr2/u6rXYV5OePtVUJY vtPLn934yMumoAYQL6Oa9tNhWvoyXiVscqffRM2Oqx5wb6NF6sj7ZYyPV7EAxE99W5gE VfaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:date:from:references:in-reply-to :message-id:dkim-signature; bh=xq+qB+6LSBSIw4B37E9JgHNJIm1VN9v6g48FmouXfvs=; b=N80p+LCE5t8OQkwb+HXY00Tim0DBesnoXYstYnMIuwTt6Dx+bpnTkEVDRPRCiVS1S3 i//2fpKnXolQD2JZBRlxRZsbEd/KLrUaQEBUDmrawHgxyesOIeWAfPak0JtXwY2tXGhg LsIq/+SYSx0LruPVcmZq2uzlUnp5R3CinPwg3perJiSeNficelTHKdMljgfGkRjbA0/a vhf/otmw6glj3+KYoFXo8Egt1f+JuOoR93mZa0/p+/KMy5hgY9ShU9qNgmzdsYWJFe7N 3HEE3FhUjcYb0TSXfQ0Cj1KgrV+ceHLMLcLWviPUScD0giL6jyPQ+Jj8x6qDVTop4s3K 57XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crudebyte.com header.s=lizzy header.b=Iizer5m+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020a056402400f00b004376b600290si14835369eda.350.2022.07.12.09.35.16; Tue, 12 Jul 2022 09:35:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@crudebyte.com header.s=lizzy header.b=Iizer5m+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233886AbiGLPzy (ORCPT + 99 others); Tue, 12 Jul 2022 11:55:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233764AbiGLPzn (ORCPT ); Tue, 12 Jul 2022 11:55:43 -0400 X-Greylist: delayed 2336 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 12 Jul 2022 08:55:42 PDT Received: from lizzy.crudebyte.com (lizzy.crudebyte.com [91.194.90.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FD6FC4470 for ; Tue, 12 Jul 2022 08:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=xq+qB+6LSBSIw4B37E9JgHNJIm1VN9v6g48FmouXfvs=; b=Iizer 5m+yT4yIEgA8pfP+JqDQ+kLypZzQY91RErkvjS8Os51RSQUW+Qeipo6S5lDzUOb7v5PDSS7ddiOXR tzWbbKLJ3sg2WHvoF1WYEc7HFsmPkP9kvrHgIKqhwwiSadMpBwfMs2HN2nq385zirxz4rfnQQCDWD ej4iORqTnmpXSu/ylZ1d7To1MH2Jdku6Z1tkuMvthFcpz711HOpJxf8Ruf9Lcd2vlYMiOKL2xuVRj zZwk7ryoCVgQdfNEQi9Gal0GniO/pSoA5S7uVowN6kluYWogeJa8gQM6cXFtpmC45b3CRACDdiBwA 38+bUmlBCo5WqjNwg1ZfoEV/0+OmQ==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 12 Jul 2022 16:31:09 +0200 Subject: [PATCH v5 01/11] 9p/trans_virtio: separate allocation of scatter gather list To: v9fs-developer@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Dominique Martinet , Eric Van Hensbergen , Latchesar Ionkov , Nikolay Kichukov X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The scatter gather list in struct virtio_chan currently resides as compile-time constant size array directly within the contiguous struct virtio_chan's memory space. Separate memory space and allocation of the scatter gather list from memory space and allocation of struct virtio_chan. Signed-off-by: Christian Schoenebeck --- net/9p/trans_virtio.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index b24a4fb0f0a2..2693e618080c 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -77,7 +77,7 @@ struct virtio_chan { */ unsigned long p9_max_pages; /* Scatterlist: can be too big for stack. */ - struct scatterlist sg[VIRTQUEUE_NUM]; + struct scatterlist *sg; /** * @tag: name to identify a mount null terminated */ @@ -574,6 +574,14 @@ static int p9_virtio_probe(struct virtio_device *vdev) goto fail; } + chan->sg = kmalloc_array(VIRTQUEUE_NUM, + sizeof(struct scatterlist), GFP_KERNEL); + if (!chan->sg) { + pr_err("Failed to allocate virtio 9P channel\n"); + err = -ENOMEM; + goto out_free_chan_shallow; + } + chan->vdev = vdev; /* We expect one virtqueue, for requests. */ @@ -635,6 +643,8 @@ static int p9_virtio_probe(struct virtio_device *vdev) out_free_vq: vdev->config->del_vqs(vdev); out_free_chan: + kfree(chan->sg); +out_free_chan_shallow: kfree(chan); fail: return err; @@ -728,6 +738,7 @@ static void p9_virtio_remove(struct virtio_device *vdev) kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE); kfree(chan->tag); kfree(chan->vc_wq); + kfree(chan->sg); kfree(chan); } -- 2.30.2