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 26676C433F5 for ; Wed, 12 Jan 2022 13:36:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F32D6B016A; Wed, 12 Jan 2022 08:35:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A2416B016B; Wed, 12 Jan 2022 08:35:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 742DD6B016C; Wed, 12 Jan 2022 08:35:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 4A9376B016A for ; Wed, 12 Jan 2022 08:35:59 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B4A198248D52 for ; Wed, 12 Jan 2022 13:35:58 +0000 (UTC) X-FDA: 79021733196.06.84E176E Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by imf26.hostedemail.com (Postfix) with ESMTP id 901A2140018 for ; Wed, 12 Jan 2022 13:35:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1641994557; x=1673530557; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=K4rrwv6mpFxo7bA4XMu6Y2QERsiVNIVMJqQ+UwJxNsc=; b=ZdvpCbdGGoCAYgHJNnxG9ZzMguJSWosKwI54Hfvy0zGLO/po+tUY9RAu s21LiG5p/CVObP/lJ59H8Bvcof6DInC/hdxCRgdOXsZerxKrx/fWrqatr zASfRhMaH/0Yn2cxmgdwyYFqjVy22EHwtauuZeolWLJRtAz5ei7BPgMJw U=; Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by alexa-out-sd-02.qualcomm.com with ESMTP; 12 Jan 2022 05:35:55 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg02-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2022 05:35:55 -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; Wed, 12 Jan 2022 05:35:55 -0800 Received: from [10.216.41.197] (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; Wed, 12 Jan 2022 05:35:50 -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: Wed, 12 Jan 2022 19:05:47 +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) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcdkim header.b=ZdvpCbdG; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf26.hostedemail.com: domain of quic_charante@quicinc.com designates 199.106.114.39 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com X-Stat-Signature: roowrsr67w4pexedpdgk4mpsqi7q8ery X-Rspamd-Queue-Id: 901A2140018 X-Rspamd-Server: rspam12 X-HE-Tag: 1641994556-88312 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Thanks Matthew for the review. On 1/12/2022 6:49 PM, Matthew Wilcox wrote: > 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. > ACK. >>> 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. ACK. >