Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5612919pxb; Thu, 20 Jan 2022 00:34:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTtJJmfMdeXCsAOUwHUHmzxz0oIgW4R3nz4ILWD/Qw/KiRzCO+6gJAliMhaqyc1dJfELLc X-Received: by 2002:a17:902:ba8c:b0:14a:f110:84e1 with SMTP id k12-20020a170902ba8c00b0014af11084e1mr6901433pls.7.1642667671534; Thu, 20 Jan 2022 00:34:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642667671; cv=none; d=google.com; s=arc-20160816; b=Tw0bu956PBRxuRWOhkUFSLZl1LRj97x4ey4MVEEHkqzPRkwwmldhvTHtTfCJ9TWbue k7nVShAX7YR2e3tojVUJ6oYjtCJCcOIuS16nVDif4Xi70CJHES3To/bN1QJo1cWhZKF0 HeTtPsiQimkXmgI8wjPVCpmg1pE/Rq4FwdrEt3AkjtjhwKB48w0TViZzSBeC36ISjr0d aIrEaKJDL/p/HyTtyJoIqq6isr9ihvn03qFTIbaaeYgI1BMGeAP9Kxg7O0mHCFIubuuU Vcldl9oW9dG6pDGnaJAlZQE7wta9jEHeuDl7fg3/goqfA3HM/b02vdooACJWI+X3OQ2e Elsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Cy0koQENvuH2stwxfYpHpozbkdaaMyCBsaJF92/LpXA=; b=0otLbjPLzUaFKcj+Hm6FFSpgYSYs2VVyW7jNa77l1ikPpPJWDTGOvhUr9p/BvTwxff 6DrrdAJCloXpdJRIuwr3zDHadLGuyFZPPUS7Wdh5REmZPu53lacIjRf9NaNkEokDZ16N CizwDg2DGmJPuF0NXgXQVwRKx3HDnr15ePJQQu9gj0+YHlJlslL97kejsGyQO1dqu8uD dymYDu3p121pvRdVHx9FL3fpeuMQJxLG55PX2tcrWKpT+YTZKhUhWwNKxStrkHDRBR6w gtBPScXgjj29j0dxbahHeWDOFbIENeGtcFhZWN/CNtJXMFtYJD4dyN9mmE0Jk1xJykVW CxWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=bDvLPAyu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si1768163plg.124.2022.01.20.00.34.19; Thu, 20 Jan 2022 00:34:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=bDvLPAyu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240265AbiARLfu (ORCPT + 99 others); Tue, 18 Jan 2022 06:35:50 -0500 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:33731 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234332AbiARLft (ORCPT ); Tue, 18 Jan 2022 06:35:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1642505749; x=1674041749; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=Cy0koQENvuH2stwxfYpHpozbkdaaMyCBsaJF92/LpXA=; b=bDvLPAyuo2b9v/TtdAKuz3iuvH0D6Ei5DpbbFGj6+XokWxF+CS5bFWW2 wUdnx2cO2iNlTMZccqkls4q7dBD6ypEb3O87g6u1ir/bAl8FpKoNtvjqg 2uRaKg6gVnEqOk+lROOJ4bCHYgEotlbT7SN3+fjfRG6WcNOIY3ZTWuwXB k=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 18 Jan 2022 03:35:48 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 03:35:48 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 18 Jan 2022 03:35:48 -0800 Received: from [10.216.58.242] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.19; Tue, 18 Jan 2022 03:35:44 -0800 Subject: Re: [PATCH v3 RESEND] mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for shmem To: Matthew Wilcox CC: Mark Hemment , , Andrew Morton , , , , , , , , Charan Teja Reddy References: <1641488717-13865-1-git-send-email-quic_charante@quicinc.com> <2c66ba2e-1c65-3bdd-b91e-eb8391ec6dbf@quicinc.com> <61212ffd-3505-04d7-5403-932a10d676e7@quicinc.com> From: Charan Teja Kalla Message-ID: Date: Tue, 18 Jan 2022 17:05:40 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Matthew, On 1/12/2022 7:05 PM, Charan Teja Kalla wrote: >>>>> + rcu_read_lock(); >>>>> + xas_for_each(&xas, page, end) { >>>>> + if (!xa_is_value(page)) >>>>> + continue; >>>>> + xas_pause(&xas); >>>>> + rcu_read_unlock(); >>>>> + >>>>> + page = shmem_read_mapping_page(mapping, xas.xa_index); >>>>> + if (!IS_ERR(page)) >>>>> + put_page(page); >>>>> + >>>>> + rcu_read_lock(); >>>>> + if (need_resched()) { >>>>> + xas_pause(&xas); >>>>> + cond_resched_rcu(); >>>>> + } >>>>> + } >>>>> + rcu_read_unlock(); >>> Even the xarray documentation says that: If most entries found during a >>> walk require you to call xas_pause(), the xa_for_each() iterator may be >>> more appropriate. > Yes. This should obviously be an xa_for_each() loop. In one of your patch[1], where we used xarray iterator, though most of the entries found requires to call xas_pause() but still endup in using xas_for_each() rather than xa_for_each(). Then, Should this code be changed to use xa_for_each()? The documentation also says that "The xas_for_each() iterator will expand into more inline code than xa_for_each()." [1]https://patchwork.kernel.org/project/linux-mm/patch/20200819184850.24779-4-willy@infradead.org/