From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66318C43461 for ; Mon, 14 Sep 2020 02:42:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19DF6217BA for ; Mon, 14 Sep 2020 02:42:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QKmPmz2m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726030AbgINCmX (ORCPT ); Sun, 13 Sep 2020 22:42:23 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:48197 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725965AbgINCmU (ORCPT ); Sun, 13 Sep 2020 22:42:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600051338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dAara/ChDatzgfsJw1KVRRZSOmBMiVP7kGi1yosi4Xw=; b=QKmPmz2mk9LGtTwNiSCJr697qCWvo97nbcOwZMfhtlFQGQls4NOS6b2DFOgMi8ihcpOiJf 2CsfgtiWZtjyn0XZYvSPXBKdE/XhW4uoQAUl3ikE67Y4dAKqKFmxEh20TkKkOCngjyPlhl LGmcFIY/HQnmTD9NuqwAE6MrTqSJbKE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-PMEHTvPYNtivp0j5MCgq1g-1; Sun, 13 Sep 2020 22:42:16 -0400 X-MC-Unique: PMEHTvPYNtivp0j5MCgq1g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 729CE1074658; Mon, 14 Sep 2020 02:42:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 674AE60C87; Mon, 14 Sep 2020 02:42:15 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4CED7180BACB; Mon, 14 Sep 2020 02:42:15 +0000 (UTC) Date: Sun, 13 Sep 2020 22:42:15 -0400 (EDT) From: Jason Wang To: Li Wang Cc: mst@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <1199326218.16921082.1600051335160.JavaMail.zimbra@redhat.com> In-Reply-To: <1599836979-4950-1-git-send-email-li.wang@windriver.com> References: <1599836979-4950-1-git-send-email-li.wang@windriver.com> Subject: Re: [PATCH] vhost: reduce stack usage in log_used MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.68.5.20, 10.4.195.2] Thread-Topic: vhost: reduce stack usage in log_used Thread-Index: s9yTJ0ICAZlN+4H+zWFH+IIKdn+BDA== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Original Message ----- > Fix the warning: [-Werror=-Wframe-larger-than=] > > drivers/vhost/vhost.c: In function log_used: > drivers/vhost/vhost.c:1906:1: > warning: the frame size of 1040 bytes is larger than 1024 bytes > > Signed-off-by: Li Wang > --- > drivers/vhost/vhost.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c > index b45519c..41769de 100644 > --- a/drivers/vhost/vhost.c > +++ b/drivers/vhost/vhost.c > @@ -1884,25 +1884,31 @@ static int log_write_hva(struct vhost_virtqueue *vq, > u64 hva, u64 len) > > static int log_used(struct vhost_virtqueue *vq, u64 used_offset, u64 len) > { > - struct iovec iov[64]; > + struct iovec *iov; > int i, ret; > > if (!vq->iotlb) > return log_write(vq->log_base, vq->log_addr + used_offset, len); > > + iov = kcalloc(64, sizeof(*iov), GFP_KERNEL); > + if (!iov) > + return -ENOMEM; Let's preallocate it in e.g vhost_net_open(). We don't want to fail the log due to -ENOMEM. Thanks > + > ret = translate_desc(vq, (uintptr_t)vq->used + used_offset, > len, iov, 64, VHOST_ACCESS_WO); > if (ret < 0) > - return ret; > + goto out; > > for (i = 0; i < ret; i++) { > ret = log_write_hva(vq, (uintptr_t)iov[i].iov_base, > iov[i].iov_len); > if (ret) > - return ret; > + goto out; > } > > - return 0; > +out: > + kfree(iov); > + return ret; > } > > int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, > -- > 2.7.4 > >