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 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5081C433F5 for ; Wed, 19 Jan 2022 17:48:58 +0000 (UTC) Received: from localhost ([::1]:41342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAF4s-0008Sa-18 for qemu-devel@archiver.kernel.org; Wed, 19 Jan 2022 12:48:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAEfy-0000AT-5V for qemu-devel@nongnu.org; Wed, 19 Jan 2022 12:23:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAEfw-0000su-G3 for qemu-devel@nongnu.org; Wed, 19 Jan 2022 12:23:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642612990; 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=a98wIamrGk+5KGulG6tfgZ91Vs5wH6tcALvWbX1aPtY=; b=KTDU3rCA3FdcVIpfWi3iI3txrIQhX4DGPcgAKXVGLrLUoyk5NyRdueko8kDgMh9mAzPhK/ iOLN9NlxZ+hRV62X8koa+TRNiYlRpTf6zeO7pPUxsb+i/yPD25l6a63nWdz3aLr6NpcnX1 x5+WUd9l2IB8zzk2SGot+ipisCBMnCs= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-154-5j5RgkVUPuCpy2L3UfEMag-1; Wed, 19 Jan 2022 12:23:09 -0500 X-MC-Unique: 5j5RgkVUPuCpy2L3UfEMag-1 Received: by mail-ed1-f72.google.com with SMTP id h11-20020a05640250cb00b003fa024f87c2so3244999edb.4 for ; Wed, 19 Jan 2022 09:23:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=a98wIamrGk+5KGulG6tfgZ91Vs5wH6tcALvWbX1aPtY=; b=KlBbFu5m9nhfFjBUS6O2kZuaekjKJFCbGWncXHxpWFB6GxwRQ9O/ziGYtAP0xf6EW1 e8lbUDEO7LXAAPx6fsAxeCW2tLdGHe8P8U7yojSvw2fdnOPerbil5BX6rq8VFV7f+u10 Zr9okkXW6t03EoG4YSWLKX4o+MrKc29yAmxlDFw+b+rOMPhMtdyid6tTLNFp0UXCHS8s Jsf/g/iMdgzB5kyzqUaBDXEHTEzq0OZayIh8oDgrIKRPtMBpGZh/MZiuPLeiKr26BIc7 GoDftxGSR9meS2MHNqSQT2ls+0fsjmbz/pgKZI0VmLi9K4QYTY0QH54uAoewL7uCWkcw khlw== X-Gm-Message-State: AOAM5329F/lLxw7ot9RXy36Jsw7pUX9UEGh7cD3+HwwvhshpOkntrvU2 3B1d1lEwJalAkqf/SJ7GNJz5+Ra8UuCXnt4BesiLpIncwoudkztVzeNKe4Z8sxVv4NISzj/fuuQ HVFs/xX7aLidbrIF4MiosHrTZIblNwgE= X-Received: by 2002:a2e:601:: with SMTP id 1mr24937654ljg.442.1642612988143; Wed, 19 Jan 2022 09:23:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+WBCma2uIMW8nsxelzuFP/+w0tRC48aqCH9ddN9wRNy9EQwCv3Rb5qOB8r2W21rUkuV33+i/d2U6ZA4UCFKQ= X-Received: by 2002:a2e:601:: with SMTP id 1mr24937627ljg.442.1642612987834; Wed, 19 Jan 2022 09:23:07 -0800 (PST) MIME-Version: 1.0 References: <20220106221341.8779-1-leobras@redhat.com> <20220106221341.8779-3-leobras@redhat.com> In-Reply-To: From: Leonardo Bras Soares Passos Date: Wed, 19 Jan 2022 14:22:56 -0300 Message-ID: Subject: Re: [PATCH v7 2/5] QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX To: =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lsoaresp@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=170.10.133.124; envelope-from=lsoaresp@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juan Quintela , qemu-devel , Peter Xu , Markus Armbruster , Eric Blake , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Hello Daniel, On Thu, Jan 13, 2022 at 7:42 AM Daniel P. Berrang=C3=A9 wrote: > > On Thu, Jan 13, 2022 at 06:34:12PM +0800, Peter Xu wrote: > > On Thu, Jan 13, 2022 at 10:06:14AM +0000, Daniel P. Berrang=C3=A9 wrote= : > > > On Thu, Jan 13, 2022 at 02:48:15PM +0800, Peter Xu wrote: > > > > On Thu, Jan 06, 2022 at 07:13:39PM -0300, Leonardo Bras wrote: > > > > > @@ -558,15 +575,26 @@ static ssize_t qio_channel_socket_writev(QI= OChannel *ioc, > > > > > memcpy(CMSG_DATA(cmsg), fds, fdsize); > > > > > } > > > > > > > > > > + if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) { > > > > > + sflags =3D MSG_ZEROCOPY; > > > > > + } > > > > > + > > > > > retry: > > > > > - ret =3D sendmsg(sioc->fd, &msg, 0); > > > > > + ret =3D sendmsg(sioc->fd, &msg, sflags); > > > > > if (ret <=3D 0) { > > > > > - if (errno =3D=3D EAGAIN) { > > > > > + switch (errno) { > > > > > + case EAGAIN: > > > > > return QIO_CHANNEL_ERR_BLOCK; > > > > > - } > > > > > - if (errno =3D=3D EINTR) { > > > > > + case EINTR: > > > > > goto retry; > > > > > + case ENOBUFS: > > > > > + if (sflags & MSG_ZEROCOPY) { > > > > > + error_setg_errno(errp, errno, > > > > > + "Process can't lock enough memo= ry for using MSG_ZEROCOPY"); > > > > > + return -1; > > > > > + } > > > > > > > > I have no idea whether it'll make a real differnece, but - should w= e better add > > > > a "break" here? If you agree and with that fixed, feel free to add= : > > > > > > > > Reviewed-by: Peter Xu > > > > > > > > I also wonder whether you hit ENOBUFS in any of the environments. = On Fedora > > > > here it's by default unlimited, but just curious when we should kee= p an eye. > > > > > > Fedora doesn't allow unlimited locked memory by default > > > > > > $ grep "locked memory" /proc/self/limits > > > Max locked memory 65536 65536 b= ytes > > > > > > And regardless of Fedora defaults, libvirt will set a limit > > > for the guest. It will only be unlimited if requiring certain > > > things like VFIO. > > > > Thanks, I obviously checked up the wrong host.. > > > > Leo, do you know how much locked memory will be needed by zero copy? W= ill > > there be a limit? Is it linear to the number of sockets/channels? > > IIRC we decided it would be limited by the socket send buffer size, rathe= r > than guest RAM, because writes will block once the send buffer is full. > > This has a default global setting, with per-socket override. On one box I > have it is 200 Kb. With multifd you'll need "num-sockets * send buffer". Oh, I was not aware there is a send buffer size (or maybe I am unable to recall). That sure makes things much easier. > > > It'll be better if we can fail at enabling the feature when we detected= that > > the specified locked memory limit may not be suffice. sure > > Checking this value against available locked memory though will always > have an error margin because other things in QEMU can use locked memory > too We can get the current limit (before zerocopy) as an error margin: req_lock_mem =3D num-sockets * send buffer + BASE_LOCKED Where BASE_LOCKED is the current libvirt value, or so on. What do you think? Best regards, Leo