From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE177C433EF for ; Wed, 12 Jan 2022 13:19:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D3766B0164; Wed, 12 Jan 2022 08:19:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 582C56B0165; Wed, 12 Jan 2022 08:19:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 449A36B0166; Wed, 12 Jan 2022 08:19:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id 1CD2A6B0164 for ; Wed, 12 Jan 2022 08:19:43 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AB5A8944E8 for ; Wed, 12 Jan 2022 13:19:42 +0000 (UTC) X-FDA: 79021692204.19.1F55763 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 874DF10000F for ; Wed, 12 Jan 2022 13:19:40 +0000 (UTC) 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=wuLuorQddbjw7aEhgglMwfq2kolodZvhyU9YfeKEDlw=; b=aVYltdtWanBX6X8xSwk6SPyle3 tlRiwa4UDEYoJHfluSKWkVweUGxDuhE+dCOczq0y//Kp8VGoZm4Yze+w31skTMOQX0SHpZpZe82Yo 8O4T9/Euk1DD/Vn85fkHquBSFUJMZzZ9ifRSeAODHScHfZswB4OfSGS9U/V8bPbME/llCAPQiuDNC MzsfROrKwgPHWlUlVuFjbb9PsY70Nj3RuwkNk1gj2nUT1zSrB/0CvW5kLBjfdcqjDMFTeimcXE/NR yy660pYl4GRxkt0hgMSt7wyLaOjn6ipXwaIUIijHp/kOl7JdDdsTSXKpxTeiyHL0kSV2BeKqECfhg 6YEqloKQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7dXI-0047p3-5B; Wed, 12 Jan 2022 13:19:32 +0000 Date: Wed, 12 Jan 2022 13:19:32 +0000 From: Matthew Wilcox To: Charan Teja Kalla Cc: Mark Hemment , hughd@google.com, Andrew Morton , vbabka@suse.cz, rientjes@google.com, mhocko@suse.com, surenb@google.com, shakeelb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Charan Teja Reddy Subject: Re: [PATCH v3 RESEND] mm: shmem: implement POSIX_FADV_[WILL|DONT]NEED for shmem Message-ID: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <61212ffd-3505-04d7-5403-932a10d676e7@quicinc.com> X-Rspamd-Queue-Id: 874DF10000F X-Stat-Signature: ufsbyjn3bch84tpk8w3gkz86h1e8tyho Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=aVYltdtW; dmarc=none; spf=none (imf14.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam02 X-HE-Tag: 1641993580-627603 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000035, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jan 12, 2022 at 01:51:55PM +0530, 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. > > Since every value entry found in the xarray requires me to do the > > xas_pause(), I do agree that xa_for_each() is the appropriate call here. > > Will switch to this in the next spin. Waiting for further review > > comments on this patch. > > I also found the below documentation: > xa_for_each() will spin if it hits a retry entry; if you intend to see > retry entries, you should use the xas_for_each() iterator instead. > > Since retry entries are expected, I should be using the xas_for_each() > with the corrections you had pointed out. Isn't it? No. You aren't handling retry entries at all; you clearly don't expect to see them. Just let the XArray code handle them itself.