Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp4269604ybt; Sun, 5 Jul 2020 23:48:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP2GxPBHd0TNYbshwJeLhZMeLrosCcJq1RoZ7VKHmq0Hk4Y+R4WbrUJP/8mPkxyd0O9MvD X-Received: by 2002:a05:6402:202a:: with SMTP id ay10mr56202138edb.0.1594018122518; Sun, 05 Jul 2020 23:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594018122; cv=none; d=google.com; s=arc-20160816; b=iDUFQmoT2lrkX1szE5lsoPmbn58X4MKGrBCUkoAxgYfU4CzqdhySICCyXqWkeBxvWg h42snB+wRq1EZTtjmnqaXUdjF1ph7xqKF/ygmonx64CF45L3aky3Du20MhgEc56Rv2uO DcTejZ07bQ96m6M8Gxc/qs3qVmuCqyx5Gpj5W3l68e82AlUJD+ACZ3Kpo7woZR31y1kH 6TUxnlN19uO+ZSWw7ZwwE6FTMSAwdjHqeduLzvOvgMq4y/CQXMQrijRBLBX4egQDR/D0 VWksJxq8PS4lacrKnja4erKC65NB+G0b6kKe1dX9EHy9ZFOZyhv7mJmdhjRbiSmDtyo7 JHGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ARowG2upYL1FRBFOB0ffQO34fUJQ8qsd+4GQ3s8Aw0w=; b=Km3eN2nvSBOMsuwmkUMufwTrMPqOP/DYJm7Q3XQFoPvMUXw7VduOxCfNrqDsLLAtQJ Rb37rEWqyIYdEhUiAG6lzulxuMEKV+98pMCdjWgHT7eSoEhp69t+7IwZO6PdIvRHOj+W h/gzj/alD2xzMBssaZkIRIt2+owZzMLkkfErXvHD6v10dCnD2yUCGkW8wvLzfMDtetzY vLvD1hMIOV7Z8sDRRLY9uwJxPqULlKRaFYIChr2BFDj9mD17rYl+/MAFzoZWP22ZXcyv 84Ron+iZjWPiOHbOAvx5sCxEpgI1Sps28H+422g00guGLGm5ib0oV1dJ3XBfomMxDD6W DtPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KeyRTo8i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mb18si11880407ejb.384.2020.07.05.23.48.19; Sun, 05 Jul 2020 23:48:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KeyRTo8i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728711AbgGFGqI (ORCPT + 99 others); Mon, 6 Jul 2020 02:46:08 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:57399 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727089AbgGFGqH (ORCPT ); Mon, 6 Jul 2020 02:46:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594017966; 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=ARowG2upYL1FRBFOB0ffQO34fUJQ8qsd+4GQ3s8Aw0w=; b=KeyRTo8iqGq4ZtM5DlTvVP+kWJC2Otq/rbL39FrcvAGYuIRXJ0Freed24NjJtGijinMLFp CdZhWNT0mNafp9oOOC7AwmJvAPC+egTgyXHKJSLuslGXM+Ih/jn7MnLHCt0tA1QQRVdyMk BOcb1DRAmPHFwLhqmcG45dWjXGbLj4Q= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-298-qQLL-LhFOWSI1851Wzp1Jg-1; Mon, 06 Jul 2020 02:46:01 -0400 X-MC-Unique: qQLL-LhFOWSI1851Wzp1Jg-1 Received: by mail-wr1-f71.google.com with SMTP id o25so41141035wro.16 for ; Sun, 05 Jul 2020 23:46:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ARowG2upYL1FRBFOB0ffQO34fUJQ8qsd+4GQ3s8Aw0w=; b=aiTi5mxgQYYvjytWK/cNhMxznEw4sAxQ5EfC+uAfviv8OPUZZrHIwB4fqEalu26IvR M/APLkCd7C0Z3IId6HelP6LlcxjT9lzoMqttm0Lk5NyfzGNrWbkodbSFnMXA3ZQGItr6 BQICGCgcXs5jt6/Bst+On8pWPYCMF4TEtVtUXT+54ddNwyZHBeCqWfoEI/7jAj9jhBDA GJmaC+ntIEaQm73ME8I3jcqX8oMCAA7tsSUznSXvwqcLBHIWjMyXFfPyBSGP8/B/vZrQ ZWFnAw8d+vijHP2Tghz9ygZgrCq77iCRUGEZvogERNECrqUGz2kr2xMjmOZueCI0hx6B MsMA== X-Gm-Message-State: AOAM5335Vg+AOhsYXJ2q2a0DLXx82hgj9METwkgmHgFIB2LJ3YmHzHOk t1ACr6Qsy6k0+2YjQFAOdDhNlCtkPTSlZ9dpjH/yG8lsPMQdxs4AYj4S8iEUEEKOWSZD/7VpZ86 l9I9dbQZRLeTRmrLO48kvN8vx X-Received: by 2002:adf:c551:: with SMTP id s17mr45472946wrf.330.1594017960089; Sun, 05 Jul 2020 23:46:00 -0700 (PDT) X-Received: by 2002:adf:c551:: with SMTP id s17mr45472928wrf.330.1594017959736; Sun, 05 Jul 2020 23:45:59 -0700 (PDT) Received: from localhost.localdomain ([151.29.90.54]) by smtp.gmail.com with ESMTPSA id 92sm24328066wrr.96.2020.07.05.23.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2020 23:45:59 -0700 (PDT) Date: Mon, 6 Jul 2020 08:45:57 +0200 From: Juri Lelli To: He Zhe Cc: viro@zeniv.linux.org.uk, axboe@kernel.dk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] eventfd: Enlarge recursion limit to allow vhost to work Message-ID: <20200706064557.GA26135@localhost.localdomain> References: <20200410114720.24838-1-zhe.he@windriver.com> <20200703081209.GN9670@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/07/20 19:11, He Zhe wrote: > > > On 7/3/20 4:12 PM, Juri Lelli wrote: > > Hi, > > > > On 10/04/20 19:47, zhe.he@windriver.com wrote: > >> From: He Zhe > >> > >> commit b5e683d5cab8 ("eventfd: track eventfd_signal() recursion depth") > >> introduces a percpu counter that tracks the percpu recursion depth and > >> warn if it greater than zero, to avoid potential deadlock and stack > >> overflow. > >> > >> However sometimes different eventfds may be used in parallel. Specifically, > >> when heavy network load goes through kvm and vhost, working as below, it > >> would trigger the following call trace. > >> > >> - 100.00% > >> - 66.51% > >> ret_from_fork > >> kthread > >> - vhost_worker > >> - 33.47% handle_tx_kick > >> handle_tx > >> handle_tx_copy > >> vhost_tx_batch.isra.0 > >> vhost_add_used_and_signal_n > >> eventfd_signal > >> - 33.05% handle_rx_net > >> handle_rx > >> vhost_add_used_and_signal_n > >> eventfd_signal > >> - 33.49% > >> ioctl > >> entry_SYSCALL_64_after_hwframe > >> do_syscall_64 > >> __x64_sys_ioctl > >> ksys_ioctl > >> do_vfs_ioctl > >> kvm_vcpu_ioctl > >> kvm_arch_vcpu_ioctl_run > >> vmx_handle_exit > >> handle_ept_misconfig > >> kvm_io_bus_write > >> __kvm_io_bus_write > >> eventfd_signal > >> > >> 001: WARNING: CPU: 1 PID: 1503 at fs/eventfd.c:73 eventfd_signal+0x85/0xa0 > >> ---- snip ---- > >> 001: Call Trace: > >> 001: vhost_signal+0x15e/0x1b0 [vhost] > >> 001: vhost_add_used_and_signal_n+0x2b/0x40 [vhost] > >> 001: handle_rx+0xb9/0x900 [vhost_net] > >> 001: handle_rx_net+0x15/0x20 [vhost_net] > >> 001: vhost_worker+0xbe/0x120 [vhost] > >> 001: kthread+0x106/0x140 > >> 001: ? log_used.part.0+0x20/0x20 [vhost] > >> 001: ? kthread_park+0x90/0x90 > >> 001: ret_from_fork+0x35/0x40 > >> 001: ---[ end trace 0000000000000003 ]--- > >> > >> This patch enlarges the limit to 1 which is the maximum recursion depth we > >> have found so far. > >> > >> Signed-off-by: He Zhe > >> --- > > Not sure if this approch can fly, but I also encountered the same > > warning (which further caused hangs during VM install) and this change > > addresses that. > > > > I'd be interested in understanding what is the status of this problem/fix. > > This is actually v2 of the patch and has not got any reply yet. Here is the v1. FYI. > https://lore.kernel.org/lkml/1586257192-58369-1-git-send-email-zhe.he@windriver.com/ I see, thanks. Hope this gets reviewed soon! :-) > > On a side note, by looking at the code, I noticed that (apart from > > samples) all callers don't actually check eventfd_signal() return value > > and I'm wondering why is that the case and if is it safe to do so. > > Checking the return value right after sending the signal can tell us if the > event counter has just overflowed, that is, exceeding ULLONG_MAX. I guess the > authors of the callers listed in the commit log just don't worry about that, > since they add only one to a dedicated eventfd. OK. I was mostly wondering if returning early in case the WARN_ON_ONCE fires would cause a missing wakeup for the eventfd_ctx wait queue. Best, Juri