From nobody Tue Apr 7 11:20:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21641C433FE for ; Fri, 14 Oct 2022 08:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230106AbiJNIHO (ORCPT ); Fri, 14 Oct 2022 04:07:14 -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-Google-Smtp-Source: AMsMyM7TCUHthbVDEp84KteEgCPGCvN3NhsLBH4YrIOYaqV0E051pLrr551rlUd5+pw1LXug+HVuIA== 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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 *f= ile, struct poll_table_struct *poll) { struct cachefiles_cache *cache =3D file->private_data; + struct xarray *xa =3D &cache->reqs; + struct cachefiles_req *req; + unsigned long index; __poll_t mask; =20 poll_wait(file, &cache->daemon_pollwq, poll); mask =3D 0; =20 if (cachefiles_in_ondemand_mode(cache)) { - if (!xa_empty(&cache->reqs)) - mask |=3D EPOLLIN; + if (!xa_empty(xa)) { + xa_for_each_marked(xa, index, req, CACHEFILES_REQ_NEW) { + if (!cachefiles_ondemand_is_reopening_read(req)) { + mask |=3D EPOLLIN; + break; + } + } + } } else { if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags)) mask |=3D 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 cachefi= les_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 =3D=3D CACHEFILES_OP_READ; +} + #else static inline ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_ca= che *cache, char __user *_buffer, size_t buflen) @@ -353,6 +360,11 @@ static inline int cachefiles_ondemand_init_obj_info(st= ruct cachefiles_object *ob { return 0; } + +static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles= _req *req) +{ + return false; +} #endif =20 /* --=20 2.20.1