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 E958CC433DB for ; Wed, 27 Jan 2021 09:15:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E28C20756 for ; Wed, 27 Jan 2021 09:15:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234708AbhA0JOz (ORCPT ); Wed, 27 Jan 2021 04:14:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235068AbhA0JMM (ORCPT ); Wed, 27 Jan 2021 04:12:12 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4493BC06174A for ; Wed, 27 Jan 2021 01:11:31 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id g12so1586382ejf.8 for ; Wed, 27 Jan 2021 01:11:31 -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=TfZZl8PAbAVTCtt4nQNes7IujOJMmLRPRF7/Y9rK9Vo=; b=b+Lnk6LAE+nkp9wqxfFccb4OZYzBekoFCPCbN7XcGTePmZI3QYVJe+OFWdJF900gZ6 YXnX0bukQa2tQ1sBU5qLTNPm31IRL0XGFR1C6pXYJtTkCQhs1iEsLBfrYg2Ek3SzoyyT 6KWsC/5GeTXsVIEfBLkd1athnsj98/OEZD/9s9LAJjKggqL2qysrfu+xaMXI4bkla47S CASUq4Msm1c6I3O9dABNjYGnDB47sYYZwN6v8AAcNywGqh2LyO4ZgcE5yDtS8U2qkxEf 9bpISs16P0RhojAJSEhYAt4IyQph+dXaFkjo8z+EzsZOoOsCp6Z28eGat8mHoDgHm+vy g7Uw== 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=TfZZl8PAbAVTCtt4nQNes7IujOJMmLRPRF7/Y9rK9Vo=; b=cTGk0dEbS7kId2tJLsKtkrMEdhwAC5zQVz/21Fe/8noWMIhDnZDwZ3o+SP9UiOXIMp v1REJ3VdBODCIuRln3TgqK8DdWXTEAeK2qdCOINL7FOYyUj/c6FZEs/gWYVcO4oYMNYu uBv2UnbMaemj6u6s/ZXNyNdC+fYR1sdQD7WEWUp7P51r2efe2924uZZYCcGgLM1zPEGq Wc4gk0FB7ORxRHK9BiGBJ6jPZK+BMN3XkghK8nkgFsPtx0kvC+poY7hnxnjJTkyjO+D7 gdSE91/wxgU5ioI9ZW5Giopbbn6o3myEGY6OevimJNXxIgw/xLIBp7hjRU6/eG1mpXhn n1BA== X-Gm-Message-State: AOAM533XqBBAcOROmoCOwZNvPU0g+fVAFevT/HNQFWMLgRAgL/vrHVgU yukfCdkMvUNk28eUj5OcFAKaNq6vo16sP5226mIx X-Google-Smtp-Source: ABdhPJypBm0DEUs9BOCccci8Ote3fGceFY3ywzu2SqtiZ/6zSNasUSc1CJB6p1slbKSfi/mwEWK1VX09P8/HKmZz0XQ= X-Received: by 2002:a17:907:3d86:: with SMTP id he6mr6036372ejc.174.1611738689957; Wed, 27 Jan 2021 01:11:29 -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: <6a5f0186-c2e3-4603-9826-50d5c68a3fda@redhat.com> From: Yongji Xie Date: Wed, 27 Jan 2021 17:11:19 +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 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 wrote= : > >> > >> 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_ctx > >>> 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 eventf= d. > >> > >> 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. Thanks, Yongji