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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 05B2FC433DB for ; Thu, 28 Jan 2021 04:08:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A54B464D92 for ; Thu, 28 Jan 2021 04:08:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231390AbhA1EHu (ORCPT ); Wed, 27 Jan 2021 23:07:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbhA1EGf (ORCPT ); Wed, 27 Jan 2021 23:06:35 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09E7BC0617A7 for ; Wed, 27 Jan 2021 19:52:58 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id gx5so5742844ejb.7 for ; Wed, 27 Jan 2021 19:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=+O2qMiPa6DUHQGJGAVdYPz1g1ToZM+iWzcVRsrY0Xi8=; b=cWVeFbmTHgO16wYgh40uSg+31tascuZOZGOnAVpdbRi9aI/sw1iSNSjNGZlY4fZrHI Yr/cjYT6LahUKE4PZ/ukO5cBl32ntZ1Nj2Usso+D7lateBQZkMOOvUKzggpEjrsZbVSt p6qFA7TycMwqn/IsSqvCB2nh7lzVpaM/bPqGmayDPbHbmvvKG2yhWXgLzOlfK4WjotTC RylAk5xck6CSApCMP8OHFiqcFTTfYaMTXEXqz80EfLXTpbgAm9Im5cugb3EvTNA5r4bT m/rKxQ1qYCHWx/xV/9cSaInXcxQTWnJKKR2l7q0P/7faYgVLJWyh0mHJSswcuqaFPfCM +pyw== 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:content-transfer-encoding; bh=+O2qMiPa6DUHQGJGAVdYPz1g1ToZM+iWzcVRsrY0Xi8=; b=b0ssF5WHW23Ndrv6QTYwyePzqq4R5GvkVN3ItIJ9JDw13Wv/ZmebtxOLE/not9sibP 01Mg4/51nCXtv2FhgZXNn6dWhIGmYjinX65cDoNArHjXWnpBecVfPIeivFxRt8uo1CIG JBrGqIR9uehjx5Q0xywqTYgF8nmfVdj2ZyGJXhFRmJIwoujzzMg797Tf3gYgpH0ze2yv +vz8Q9qr3oy84QZwstjnO/s+YetWdTC2AFX8uywyb/DF4jZc3b6ZCE3qqIBUHvSmJLnC 0Em9pHNzAv9l6lxBwEktvYrdw3l+Hp9LrfwGvNRLxe+mhiCuaRhOAww4AHbUiIFaTWUg ZxfQ== X-Gm-Message-State: AOAM532kOG5D1Ql5iclVpGkUi8wM2raTqIh17Rocl0UKvUjteuZKXlaa tkXlzB5eEUZo0tVlVevXfImnFCqlHZctEHSRb4+H X-Google-Smtp-Source: ABdhPJzTganDrHuz8JhcC1ya1QviFsDqnAscuVEhbF7bZ5b0uFePTtg2FCy+ZiWVARQ6EkK0Zu2XAwYNJMdtwF0Ttcg= X-Received: by 2002:a17:907:1629:: with SMTP id hb41mr8917531ejc.197.1611805976826; Wed, 27 Jan 2021 19:52:56 -0800 (PST) MIME-Version: 1.0 References: <20210119045920.447-1-xieyongji@bytedance.com> <20210119045920.447-2-xieyongji@bytedance.com> <6a5f0186-c2e3-4603-9826-50d5c68a3fda@redhat.com> In-Reply-To: From: Yongji Xie Date: Thu, 28 Jan 2021 11:52:45 +0800 Message-ID: Subject: Re: Re: [RFC v3 01/11] eventfd: track eventfd_signal() recursion depth separately in different cases To: Jason Wang Cc: "Michael S. Tsirkin" , Stefan Hajnoczi , Stefano Garzarella , Parav Pandit , Bob Liu , Christoph Hellwig , Randy Dunlap , Matthew Wilcox , viro@zeniv.linux.org.uk, axboe@kernel.dk, bcrl@kvack.org, Jonathan Corbet , virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, Jan 28, 2021 at 11:05 AM Jason Wang wrote: > > > On 2021/1/27 =E4=B8=8B=E5=8D=885:11, Yongji Xie wrote: > > On Wed, Jan 27, 2021 at 11:38 AM Jason Wang wrote= : > >> > >> On 2021/1/20 =E4=B8=8B=E5=8D=882:52, Yongji Xie wrote: > >>> On Wed, Jan 20, 2021 at 12:24 PM Jason Wang wro= te: > >>>> On 2021/1/19 =E4=B8=8B=E5=8D=8812:59, Xie Yongji wrote: > >>>>> Now we have a global percpu counter to limit the recursion depth > >>>>> of eventfd_signal(). This can avoid deadlock or stack overflow. > >>>>> But in stack overflow case, it should be OK to increase the > >>>>> recursion depth if needed. So we add a percpu counter in eventfd_ct= x > >>>>> to limit the recursion depth for deadlock case. Then it could be > >>>>> fine to increase the global percpu counter later. > >>>> I wonder whether or not it's worth to introduce percpu for each even= tfd. > >>>> > >>>> How about simply check if eventfd_signal_count() is greater than 2? > >>>> > >>> It can't avoid deadlock in this way. > >> > >> I may miss something but the count is to avoid recursive eventfd call. > >> So for VDUSE what we suffers is e.g the interrupt injection path: > >> > >> userspace write IRQFD -> vq->cb() -> another IRQFD. > >> > >> It looks like increasing EVENTFD_WAKEUP_DEPTH should be sufficient? > >> > > Actually I mean the deadlock described in commit f0b493e ("io_uring: > > prevent potential eventfd recursion on poll"). It can break this bug > > fix if we just increase EVENTFD_WAKEUP_DEPTH. > > > Ok, so can wait do something similar in that commit? (using async stuffs > like wq). > We can do that. But it will reduce the performance. Because the eventfd recursion will be triggered every time kvm kick eventfd in vhost-vdpa cases: KVM write KICKFD -> ops->kick_vq -> VDUSE write KICKFD Thanks, Yongji