Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp141428rwe; Tue, 18 Apr 2023 19:17:12 -0700 (PDT) X-Google-Smtp-Source: AKy350a6B3y4rsJrWuL0d9NpWupjM7Yj4/me+KTiTsedMaAPmcrv/8ZkymX3I4QZpMWeDrd0pfVQ X-Received: by 2002:a17:90a:9d85:b0:233:ee67:8eb3 with SMTP id k5-20020a17090a9d8500b00233ee678eb3mr1446338pjp.24.1681870632013; Tue, 18 Apr 2023 19:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681870631; cv=none; d=google.com; s=arc-20160816; b=eBs9+1oyz5SrbzYXi4eXKA7UPZelKc0viN8bjjQoO+BHAjpguGT52rzhR/671NddaJ sfmGgDwE0E4EtDuMVKifMwVSUoqnFFBEy16Vk670j8o/oUat9AlCbjkG5V10XqW7It7S jYDtGbZlGukfYRbXQCJI1F4Fxuzo83LIYQyzasM8aOhBd4egPC15B3b8csul4q+u0aso zgxadNhrpwn7FKCU1FYs/bON2cMvoiLxNoamcmEEXbKMTU6SUTlhuNnzRwsGIuXYYVMs 7wNkXmCR0wsxyCheE+qaO4c8EnMH4ziaNZFw21gFJTZYBhbLkn7/NyJC3xctKzcee0xR MJvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=omaGeiilnWY8neqCu1aYblokWGcDA5y3QiHgOwpl4SY=; b=XgreUXND4xAanJPK5biLrQVai23S1DUZ5oLurKIhaZLiboppS2pnOVPHBF9ITWB3On FfY9NI6j0s7bIeiv1f/NOt0dFbEt9TmJSFdlwPlIzVIybCarnwwbpHG4SFcBBgnmnWqV rSV/r4CBqI/+wegQAi6foPillLrmQdeMkeRvGVXhHk16Re2d9drYhJ5QyV9nExkJjidm 2AFKDaNVfaltNLB0VysUpmd4I9Gp0mGdceuKLND+k0hz8gKI4qKvhjHEAhbOKNSn/Bqe yGI4qY2tFPh6MQYwnfTGxlj/U1HsiT5aRyjwgOn28B4iVDNV6N4z3Rj2VcaUoIDRalqy WgJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=jDO842tO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a656a11000000b0050f74bf6b3asi17312186pgu.700.2023.04.18.19.16.59; Tue, 18 Apr 2023 19:17:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=jDO842tO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbjDSCPJ (ORCPT + 99 others); Tue, 18 Apr 2023 22:15:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjDSCPH (ORCPT ); Tue, 18 Apr 2023 22:15:07 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B455124 for ; Tue, 18 Apr 2023 19:15:05 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-63d32d21f95so400529b3a.1 for ; Tue, 18 Apr 2023 19:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20221208.gappssmtp.com; s=20221208; t=1681870505; x=1684462505; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=omaGeiilnWY8neqCu1aYblokWGcDA5y3QiHgOwpl4SY=; b=jDO842tOQzUGfFMlpnl+0xVX3t6R3u7QMAu+s1WrMuaCVxUVgycP/Phvb0HoNh58iV xLOhkc8EW1Ikvbi+/i+Dg6fvhkyMeYlA+FTVKE2RrVK3A7rpc+FzJHUxR0wTQ7QQ26t8 L2EaQEaUlrIPN0uaaIg3XDMhAKNjBJvO8Eea6E4VzoBpfKrX4OSVA4FK7j2bOxK6lK/H E4/tztiAvNCbQPn0euQIadpatwx8hSQCAS1/vzs89ylaAlw3oJekdbSEM5Fm92E+AwLm 6hoKbSPftzXTPPbgVF0j/C7FHTHfnxNNnOccSwEzcnySOyWOL8bIUJZfLr1m5oTSOXTu 9U0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681870505; x=1684462505; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=omaGeiilnWY8neqCu1aYblokWGcDA5y3QiHgOwpl4SY=; b=L3r5SBcKBZ7kIqPZaHQJgX+AEzYhSYdVTiQW+INhT+CmAL2M6d7IpOAOEnTRhX7j4K TCSaJkO37jCeIyntog81H7tyrC7x7dF+H7gtW9u3rwINSlVvy9BIJiyABOrYE+ZTnNNY +Xcut868E01bYUQnuKccz4CJICHuk2En8nOAZvL72bjixRKkkfqwqxZbdrZTs5TXi5Fi bjTqQ+FIg3CoKqUUCUQ9uCqmhlfh0h8ALkbf/JFM04ickDz3FitAhTUd6skAGXjn3WHf Sae6lvB5c4i/eWUMRme3hI84Y1jp7+d5n4ctpc34OxUCeFZWPhXhsf/u3IsMWmeSruK/ 8UQg== X-Gm-Message-State: AAQBX9e7tMM3pa7ieDMCUS2nmTBY4JnoO5H0MUr97m+mucSWPxU6mUAB ShrCYeI5pU6FaFVkvfEvwcL+IA== X-Received: by 2002:a05:6a00:44c6:b0:638:2493:1710 with SMTP id cv6-20020a056a0044c600b0063824931710mr16865100pfb.3.1681870505004; Tue, 18 Apr 2023 19:15:05 -0700 (PDT) Received: from [192.168.1.136] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id c18-20020aa78812000000b0063b73e69ea2sm7275709pfo.42.2023.04.18.19.15.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Apr 2023 19:15:04 -0700 (PDT) Message-ID: <7dded5a8-32c1-e994-52a0-ce32011d5e6b@kernel.dk> Date: Tue, 18 Apr 2023 20:15:03 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] eventfd: support delayed wakeup for non-semaphore eventfd to reduce cpu utilization Content-Language: en-US To: Wen Yang , Alexander Viro , Christian Brauner Cc: Christoph Hellwig , Dylan Yudaken , David Woodhouse , Paolo Bonzini , Fu Wei , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <817984a2-570c-cb23-4121-0d75005ebd4d@kernel.dk> From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/17/23 10:32?AM, Wen Yang wrote: > > ? 2023/4/17 22:38, Jens Axboe ??: >> On 4/16/23 5:31?AM, wenyang.linux@foxmail.com wrote: >>> From: Wen Yang >>> >>> For the NON SEMAPHORE eventfd, if it's counter has a nonzero value, >>> then a read(2) returns 8 bytes containing that value, and the counter's >>> value is reset to zero. Therefore, in the NON SEMAPHORE scenario, >>> N event_writes vs ONE event_read is possible. >>> >>> However, the current implementation wakes up the read thread immediately >>> in eventfd_write so that the cpu utilization increases unnecessarily. >>> >>> By adding a configurable delay after eventfd_write, these unnecessary >>> wakeup operations are avoided, thereby reducing cpu utilization. >> What's the real world use case of this, and what would the expected >> delay be there? With using a delayed work item for this, there's >> certainly a pretty wide grey zone in terms of delay where this would >> perform considerably worse than not doing any delayed wakeups at all. > > > Thanks for your comments. > > We have found that the CPU usage of the message middleware is high in > our environment, because sensor messages from MCU are very frequent > and constantly reported, possibly several hundred thousand times per > second. As a result, the message receiving thread is frequently > awakened to process short messages. > > The following is the simplified test code: > https://github.com/w-simon/tests/blob/master/src/test.c > > And the test code in this patch is further simplified. > > Finally, only a configuration item has been added here, allowing users > to make more choices. I think you'd have a higher chance of getting this in if the delay setting was per eventfd context, rather than a global thing. -- Jens Axboe