From nobody Tue Apr 7 11:20:07 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 30AD9C4332F for ; Fri, 14 Oct 2022 03:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbiJNDJ3 (ORCPT ); Thu, 13 Oct 2022 23:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiJNDIk (ORCPT ); Thu, 13 Oct 2022 23:08:40 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA5BEF589 for ; Thu, 13 Oct 2022 20:08:38 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id y10so2497699qvo.11 for ; Thu, 13 Oct 2022 20:08:38 -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=i1R7QPYLS3htwC9+m+eMmhkdxMHPXqw45xmXhqmncaA=; b=22pn9Os6EXT6UWfc9ZeKQ71GM5Bhmq9AlSEpgZrKl0IUo/yufgpYJMahaOmGApuHFQ 0HjgOrbOd3sJY2g4HJFuY1sgb4TaAlQP3aRsz10/ANjJZl4lMgHQsK7sWfd8Y0DMkh+C Dnl17PUMBTdKkOZPaPAnFJ/golfWNeftyDK3tNB7RN8JVIyFOYWbhGQkwRm4hg/oIKKh XWwkEhfZvnj2wPG3jNFSKte8oOALG7BsAxuzpit/Iy/IXoZtVY0BmdVKoGN2ayiG8T6J v607OE1Wb3Zg/vDA9PphT7Zvanzlont5JanwatBkMlDh5o+XUUb8SSx2FdIDrQQBfhxj TvmQ== 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=i1R7QPYLS3htwC9+m+eMmhkdxMHPXqw45xmXhqmncaA=; b=v8eFqwasSqR6d6qnnZUA3+fD9lePasmA8LOWHABddfNqiQ33yxVrt/JKLum33vYO96 fCSI/mmRBM5UIeMUALWMJ4YntWKqNFZ4K87ZUZcIYtSBI7l24dRw9o7+11FQGK78Jv/s bkvtV+ZSMcHNPQagG1Ro0TpWs49SrsjcH8gQCQh+ONXCh2Q69l3NOdiPBlyNn4ZUURFo j8iJazB6cM2Ib/qOiN8kFMIcmaZ2RhPYw+UzhHnhXcO68/ijta6ysS8AdiiChPtWEb1R PonYFGQ4yXSXoHCP8rc1Grv/8IQ7UGrVoatI44PKyShoNVUgl/3ClnmW4L1wiBGY8bKf dAOw== X-Gm-Message-State: ACrzQf1uvsFB4U4/B0aU3Q7Isya9b9OPAb97WawJgzDI5N7K8SS+8xhx T4TnmZk8zYdxCWFRih5CHaCVwZFbThkO5dOh X-Google-Smtp-Source: AMsMyM5Ejyc0D+AQNsiKQu3QB+Vg9yCW8ZNFcTSVKsMfVupUu0uJQ3sNLvSheHGNJWaShgZirb4OmA== X-Received: by 2002:a17:903:1003:b0:181:6c26:1114 with SMTP id a3-20020a170903100300b001816c261114mr2921922plb.75.1665716906763; Thu, 13 Oct 2022 20:08:26 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([63.216.146.183]) by smtp.gmail.com with ESMTPSA id h4-20020a17090a710400b0020ae09e9724sm425524pjk.53.2022.10.13.20.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 20:08:26 -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 V2 4/5] cachefiles: narrow the scope of triggering EPOLLIN events in ondemand mode Date: Fri, 14 Oct 2022 11:07:44 +0800 Message-Id: <20221014030745.25748-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20221014030745.25748-1-zhujia.zj@bytedance.com> References: <20221014030745.25748-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 21ef5007f488..98d6cf58db11 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -327,6 +327,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) @@ -354,6 +361,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