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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 D9CA0C433F5 for ; Wed, 8 Sep 2021 03:31:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 927786108B for ; Wed, 8 Sep 2021 03:31:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 927786108B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNoJ1-00012a-KD for qemu-devel@archiver.kernel.org; Tue, 07 Sep 2021 23:31:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNoEU-0004hB-VT for qemu-devel@nongnu.org; Tue, 07 Sep 2021 23:26:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNoER-0004g1-VZ for qemu-devel@nongnu.org; Tue, 07 Sep 2021 23:26:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631071598; 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: in-reply-to:in-reply-to:references:references; bh=hnKoI6cp1QJAs0ChyRvdHqGPuT+uHEFcveZqYISKPI8=; b=Y6Qnv32sFFJEhapoTp3qK1ui2SeFeGza3emUj0FYrbddwgweQ00vRktSDpq8w42Q7wA3i0 KYPFLiIuJ0pMYZk3Xez/1LpVm1KYcf1xC6VUwm1LN49G1HnA3SrlMiwspDZcOMo+BPrQBH P1Ql0o4eFR+FpG4ltboAeHKPfupvs8w= Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-601-QE4_7otTPPinZm59R9FE-g-1; Tue, 07 Sep 2021 23:26:37 -0400 X-MC-Unique: QE4_7otTPPinZm59R9FE-g-1 Received: by mail-yb1-f198.google.com with SMTP id b84-20020a253457000000b0059e6b730d45so857659yba.6 for ; Tue, 07 Sep 2021 20:26:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hnKoI6cp1QJAs0ChyRvdHqGPuT+uHEFcveZqYISKPI8=; b=MLuPyNMe/HP3ubkT3w/RnMSi3Wql/cYnjwxSosQaCgEQSnRqt1uAP7L6jlwetHDKAE SjdaVsaw+uCqw1jWuMWwB9jyHbJzfGz77vXxDawzwAHl8Rx7+di5wZNPqKDCQJYLNVFM dv8J/3yglDRygfcoVVtURPoydTuWl3GKYgrZ6X73oWq3mbcNBbvkG0E+tJqQWc/1WSZW /cFjtZBcNp4TAfeRf88ZZuwmv7AQzctFaSeXtb7sv1D/JxBv3cy1YYS125hguP3QRCNr Ca3BRhDikfwiLcOmy5U/z4LoBO/YJPTQpyLxI2Jyx8WRWnIJyi1VnnwPVtASq9Uh0Gwm yS1A== X-Gm-Message-State: AOAM533a30xkmYn8N+HSg/6HF7NPO8osikPQy9hecQt7bHjV7LgsPQFZ lreeYPojMKH8ZHaVnciNmWdJFNuohWaLsde8lV+LcjGvB2p959Xo1di+G9Ik71yhWTPrK8GBLHd MTVvCZIjcPoz4vjWFe+qjWEk6UC83RD8= X-Received: by 2002:a25:b98b:: with SMTP id r11mr2097927ybg.189.1631071596727; Tue, 07 Sep 2021 20:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy7f3On/wQ+m2cjdGx0Z6oxp5XQPU/2r3cUGI8tNyW6lTbO6G1IghRH6E+lluXn8//TCdK58sCdxq0JdAS29Y= X-Received: by 2002:a25:b98b:: with SMTP id r11mr2097912ybg.189.1631071596520; Tue, 07 Sep 2021 20:26:36 -0700 (PDT) MIME-Version: 1.0 References: <20210831110238.299458-1-leobras@redhat.com> <20210831110238.299458-4-leobras@redhat.com> In-Reply-To: From: Jason Wang Date: Wed, 8 Sep 2021 11:26:25 +0800 Message-ID: Subject: Re: [PATCH v1 3/3] migration: multifd: Enable zerocopy To: Peter Xu Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.391, 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_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Elena Ufimtseva , John G Johnson , =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , qemu-devel , Leonardo Bras Soares Passos , Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Fam Zheng , Jagannathan Raman Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wed, Sep 8, 2021 at 11:24 AM Peter Xu wrote: > > On Wed, Sep 08, 2021 at 10:59:57AM +0800, Jason Wang wrote: > > On Wed, Sep 8, 2021 at 2:32 AM Peter Xu wrote: > > > > > > On Thu, Sep 02, 2021 at 04:22:55AM -0300, Leonardo Bras Soares Passos wrote: > > > > > I don't think it is valid to unconditionally enable this feature due to the > > > > > resource usage implications > > > > > > > > > > https://www.kernel.org/doc/html/v5.4/networking/msg_zerocopy.html > > > > > > > > > > "A zerocopy failure will return -1 with errno ENOBUFS. This happens > > > > > if the socket option was not set, the socket exceeds its optmem > > > > > limit or the user exceeds its ulimit on locked pages." > > > > > > > > You are correct, I unfortunately missed this part in the docs :( > > > > > > > > > The limit on locked pages is something that looks very likely to be > > > > > exceeded unless you happen to be running a QEMU config that already > > > > > implies locked memory (eg PCI assignment) > > > > > > > > Do you mean the limit an user has on locking memory? > > > > > > > > If so, that makes sense. I remember I needed to set the upper limit of locked > > > > memory for the user before using it, or adding a capability to qemu before. > > > > > > So I'm a bit confused on why MSG_ZEROCOPY requires checking RLIMIT_MEMLOCK. > > > > > > The thing is IIUC that's accounting for pinned pages only with either mlock() > > > (FOLL_MLOCK) or vfio (FOLL_PIN). > > > > > > I don't really think MSG_ZEROCOPY is doing that at all... I'm looking at > > > __zerocopy_sg_from_iter() -> iov_iter_get_pages(). > > > > It happens probably here: > > > > E.g > > > > __ip_append_data() > > msg_zerocopy_realloc() > > mm_account_pinned_pages() > > Right. :) > > But my previous question is more about the reason behind it - I thought that's > a common GUP and it shouldn't rely on locked_vm because it should still be > temporary GUP rather than a long time GUP, IMHO that's how we use locked_vm (we > don't account for temp GUPs but only longterm ones). IOW, I'm wondering whether > all the rest of iov_iter_get_pages() callers should check locked_vm too, and > AFAIU they're not doing that right now.. You are probably right, but I'm not sure if it's too late to fix that. (E.g it will break existing userspace) Thanks > > Thanks, > > -- > Peter Xu >