Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2252092pxp; Mon, 21 Mar 2022 15:02:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyah6S1aBnvkrk9u4cyIThRKmFul0F3VTn2gyrjEKvIv/pcRlqINzp1lpG+nRbzxvVw/A4 X-Received: by 2002:a17:90b:1b4e:b0:1c6:fff4:34dc with SMTP id nv14-20020a17090b1b4e00b001c6fff434dcmr1317394pjb.76.1647900135550; Mon, 21 Mar 2022 15:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647900135; cv=none; d=google.com; s=arc-20160816; b=Y6gDWKIp2Ynybl6YLhBXaU6wTyxyYNkkWOnGNold92I+xCt9EL3FhoYLpuuctPzpWS ErGZW2M2Y4euddDtdZgm5OSBL4pEa149T4AVLLT+vubcfnEK2qnLOTYWv4dwLsGV9QDD 0DdN7tuddBPpOE1hbplXLKcUjP6c/tLwQ/Gt47kfu9FdyYk4JiFxGt41p/+SdD+Nyljn roS/rXhBktQ87/ur2TOGWiUGmgOBvraRcUWkXG3tl7OrSHziehfzB2eekDZTnZ1HYn7z tKA3jY839HA7KIZY4euvuPPuHx05xsAVSH//nHXdNfUAOBuXd6CjC8Fk9UwL6SBazbTs Tgwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yjHmNUrTcsfBaaW2FV8OWLDc9yEfNnCQ4g7zaOGPWqs=; b=fmPNtNfXuncaqPrXwW9BQV+2SYMlnPdZR/agozcDP5C6o5Pv/P7QCmZDameJRWFMoL LUmr64eh+wdsYS7RBjY6kSdbwS/0oWzvYxvYdRs5vl2/0+D45aOWSrWLtv6acWhuxc1n u0LounRSTnnoKxroLB9xjmEc8BFLxfWq+9ZDMoodR5MwzXh9OZB13DvNE1sRoC5kso4+ YgLJO7EpMHBSvDuWIpNQXyk4Zi/rbeWaxlEmVW3MZvEv1Vof1DoOrdkMOVQc72XC27TJ B5s8BAxD/l1GnVDpjtHXMaz4jnYP/5jjD74CTxhwyHUAzowT9nJHoaYWCGIIJ2RgifI1 W/9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pM6u9L8P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id be12-20020a056a001f0c00b004faa6d525ddsi2671144pfb.269.2022.03.21.15.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:02:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=pM6u9L8P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6EAC112084; Mon, 21 Mar 2022 14:26:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343609AbiCUPXx (ORCPT + 99 others); Mon, 21 Mar 2022 11:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350018AbiCUPWx (ORCPT ); Mon, 21 Mar 2022 11:22:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAE754B1D9; Mon, 21 Mar 2022 08:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=yjHmNUrTcsfBaaW2FV8OWLDc9yEfNnCQ4g7zaOGPWqs=; b=pM6u9L8P999sXYeV/U2ZFRYDSN SpEi168deMKZu9jl3PQ2+oOchdAFGkGuEC8zT6guPBzxs5YkCKUmjvKUW9zwv8NvHCPKYaEiecS6t 7VDVjvBg6ESSZ7MQQSSqB+OuszsrOOcQ14kdJXG6liG6oe206cC7QFz1vnR8MkQVWicnRzRQGHMkm KVQrS63cEIfBON47cvlquRNC6Q8lsctQWTLO3kSRia4x42KS8uZKD+iflz4S52GmkYIpS8C1LJEWU frUF02UGLNlLqQ483T3LkqrTp9wKwK6BcXpsUOb61xFDTBMJAcp2KcnNDS6QpmMBXA2tqs1xBARiC FbIDCPkA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWJqI-00Ah2w-Dv; Mon, 21 Mar 2022 15:21:10 +0000 Date: Mon, 21 Mar 2022 15:21:10 +0000 From: Matthew Wilcox To: JeffleXu Cc: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, torvalds@linux-foundation.org, gregkh@linuxfoundation.org, linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org, luodaowen.backend@bytedance.com Subject: Re: [PATCH v5 03/22] cachefiles: introduce on-demand read mode Message-ID: References: <20220316131723.111553-1-jefflexu@linux.alibaba.com> <20220316131723.111553-4-jefflexu@linux.alibaba.com> <6bc551d2-15fc-5d17-c99b-8db588c6b671@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Mon, Mar 21, 2022 at 11:18:05PM +0800, JeffleXu wrote: > >> Besides, IMHO read-write lock shall be more performance friendly, since > >> most cases are the read side. > > > > That's almost never true. rwlocks are usually a bad idea because you > > still have to bounce the cacheline, so you replace lock contention > > (which you can see) with cacheline contention (which is harder to > > measure). And then you have questions about reader/writer fairness > > (should new readers queue behind a writer if there's one waiting, or > > should a steady stream of readers be able to hold a writer off > > indefinitely?) > > Interesting, I didn't notice it before. Thanks for explaining it. No problem. It's hard to notice. > BTW what I want is just > > ``` > PROCESS 1 PROCESS 2 > ========= ========= > #lock #lock > set DEAD state if (not DEAD) > flush xarray enqueue into xarray > #unlock #unlock > ``` > > I think it is a generic paradigm. So it seems that the spinlock inside > xarray is already adequate for this job? Absolutely; just use xa_lock() to protect both setting & testing the flag.