Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp283970rwi; Fri, 14 Oct 2022 01:47:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46FgjkOaIHXNxg4TIr5d4a2U+yI/mpOEIbHaZolw2hF3zFLiJ+qCYmOr0ufqyy1SwoOa4T X-Received: by 2002:a17:907:2d29:b0:78d:cf5c:5774 with SMTP id gs41-20020a1709072d2900b0078dcf5c5774mr2682371ejc.213.1665737269746; Fri, 14 Oct 2022 01:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665737269; cv=none; d=google.com; s=arc-20160816; b=G1qU4kTIh0tcgOq5qCwZpV4yGp74v8tOTU1tqhhybEbsxqka5Q5UKUwOwuFcjKwW28 AKl8hGWTqfd83IxdgImn8ETFYzPbRokWr/Yp1+8UAz508WrGJKQB9qiyIsG3WtR5wnLo ppxD8rkxGyx0YSvn+gZ0+KuDUV5ntYa5BhFvUmfoiS4iBKXkB340I0SzgjJASHGwunBb g513kfyGtxZeBMUneIQNDSwm/DrPFdfWC4cmZ7gL6jQtiOfGiPdspdtdnk68oxeSgMVk YcuAmamtjmBy5meMBy/yZRD+EPWHr80elr5m9yQpdMgpAMtPGNk001kTsvtoq99UHcUd sQzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8u8C9HdOyOb3+ICBwFZcrFBPJwehJIZsy+qDOHaF19g=; b=uvJ9Tk6cGfghf7aizGpPRmJM7dXluxel//cYRFJE4U0QShsgagvErXPDg5vJkqRMIg HfqymKT8qHqVsAliF0JOFMAeTZWxICuV+106xwAYl7I8+eeYNnSPG0yO2oYIB2ihby2i xeBmTfm4sRPpWl+BgLGlImqSpm4y5zMZKcTfwn/Lxi0ZQ34EHjBrk9sXxOkFZTeRB0Sy nwz50l0S+fIGXtu1oX5o6ZfQXaolNI2h4sfYJesAk0E55p+nqQ3aeYfUrjPjnzPIXX51 4j5Ncf+atLvCMdK6CqdTSiigkjvjKcVu2gUpplMh8cE2AEQ5xVYLYarKI+lTn/G8QS8D v97w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="PR9/JKqA"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn20-20020a1709070d1400b0078d514ace6bsi2113993ejc.282.2022.10.14.01.47.23; Fri, 14 Oct 2022 01:47:49 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="PR9/JKqA"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbiJNIHN (ORCPT + 99 others); Fri, 14 Oct 2022 04:07:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbiJNIGz (ORCPT ); Fri, 14 Oct 2022 04:06:55 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B21B1BE1DA for ; Fri, 14 Oct 2022 01:06:48 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id h10so4083954plb.2 for ; Fri, 14 Oct 2022 01:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8u8C9HdOyOb3+ICBwFZcrFBPJwehJIZsy+qDOHaF19g=; b=PR9/JKqA3+BUVhsO9JjYtGBtjxZi6CZawKro8WxV/0VxazHeT12xhp3alzz7CcN/vE knyqS/WNxyrwZ6WBVJAhIOGy9XpFWo15nnMqQIk+/acXb3/SeYy3QFly9jhTjQOCvZBD SlbDyFfwjhZXE+zZSEH/q2Hf4WKMDv5IjHBtWoEuCCknzdNmLXSo6UsSxXjZFPGZJKkE AxUZ7JRU6rdZfWzIANN+B2LEGuvx/jQwto7FKT6WeAS3QrHTepOUv9ljgAgYHp8dSWKj dnVcqoV8pNmlCvHlbhqmFcxn1Bymi7WwZKpYyCpjgghgVkGolVB/ntojWYCZVCd6+h7B lFmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8u8C9HdOyOb3+ICBwFZcrFBPJwehJIZsy+qDOHaF19g=; b=dQswAExKxzGu4kXWZPX4oxvDYdLqH5h+gIJ65BcqDOkHQQLb7YjwWXDXZ2cDRhxWpv LC+GMMLPDNqieA0R17QT+9G2CYa9TdK9NG0ZcZPm7WL18OoIxmA8y5M+7gmkLs0HzhNg T2s8xQkAFn2yAe+yEQ3RyAbKPzeZKCkIHpe40FrBCfbUqyn2Y+iw00NLe1g9nGpFQIha TKiknU3+jcb+z993yGFcaEiMpNniMzhmkuyTRresvJplT7Z2Rd1OMOTc8RZSeWA9xGld F2bv0F7bjK2kX6BG/DnBC6rOWhU9TWxtPLEPMdLwhPKdXdA5gqDNbuxMjN4fTrswpXHN voeA== X-Gm-Message-State: ACrzQf3U+02a9dblR8eajTZTvUBQp2vGIp5UQnAYAfjJoNNOnOVXi8Ik 6fI4YCRWghEzeAnksAqiOuugPw== X-Received: by 2002:a17:902:b901:b0:184:5b9a:24f0 with SMTP id bf1-20020a170902b90100b001845b9a24f0mr4142759plb.17.1665734807934; Fri, 14 Oct 2022 01:06:47 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([63.216.146.188]) by smtp.gmail.com with ESMTPSA id ik20-20020a170902ab1400b001730a1af0fbsm1119196plb.23.2022.10.14.01.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 01:06:47 -0700 (PDT) From: Jia Zhu To: dhowells@redhat.com, xiang@kernel.org, jefflexu@linux.alibaba.com Cc: linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, Jia Zhu Subject: [PATCH V3 4/5] cachefiles: narrow the scope of triggering EPOLLIN events in ondemand mode Date: Fri, 14 Oct 2022 16:05:58 +0800 Message-Id: <20221014080559.42108-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20221014080559.42108-1-zhujia.zj@bytedance.com> References: <20221014080559.42108-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Don't trigger EPOLLIN when there are only reopening read requests in xarray. Suggested-by: Xin Yin Signed-off-by: Jia Zhu Reviewed-by: Jingbo Xu --- fs/cachefiles/daemon.c | 13 +++++++++++-- fs/cachefiles/internal.h | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index aa4efcabb5e3..c74bd1f4ecf5 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -355,14 +355,23 @@ static __poll_t cachefiles_daemon_poll(struct file *file, struct poll_table_struct *poll) { struct cachefiles_cache *cache = file->private_data; + struct xarray *xa = &cache->reqs; + struct cachefiles_req *req; + unsigned long index; __poll_t mask; poll_wait(file, &cache->daemon_pollwq, poll); mask = 0; if (cachefiles_in_ondemand_mode(cache)) { - if (!xa_empty(&cache->reqs)) - mask |= EPOLLIN; + if (!xa_empty(xa)) { + xa_for_each_marked(xa, index, req, CACHEFILES_REQ_NEW) { + if (!cachefiles_ondemand_is_reopening_read(req)) { + mask |= EPOLLIN; + break; + } + } + } } else { if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags)) mask |= EPOLLIN; diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 2ed836d4169e..3d94990a8b38 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -326,6 +326,13 @@ cachefiles_ondemand_set_object_##_state(struct cachefiles_object *object) \ CACHEFILES_OBJECT_STATE_FUNCS(open); CACHEFILES_OBJECT_STATE_FUNCS(close); CACHEFILES_OBJECT_STATE_FUNCS(reopening); + +static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *req) +{ + return cachefiles_ondemand_object_is_reopening(req->object) && + req->msg.opcode == CACHEFILES_OP_READ; +} + #else static inline ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, char __user *_buffer, size_t buflen) @@ -353,6 +360,11 @@ static inline int cachefiles_ondemand_init_obj_info(struct cachefiles_object *ob { return 0; } + +static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *req) +{ + return false; +} #endif /* -- 2.20.1