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 73571D32D7E for ; Tue, 12 Nov 2024 09:47:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F37A68D0002; Tue, 12 Nov 2024 04:47:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EE5F88D0001; Tue, 12 Nov 2024 04:47:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3B508D0002; Tue, 12 Nov 2024 04:47:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B23D38D0001 for ; Tue, 12 Nov 2024 04:47:11 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3B049141BF8 for ; Tue, 12 Nov 2024 09:47:11 +0000 (UTC) X-FDA: 82776963402.23.88B8F0B Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by imf10.hostedemail.com (Postfix) with ESMTP id 6AB27C0009 for ; Tue, 12 Nov 2024 09:46:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=BY5dlkL5; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf10.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731404767; a=rsa-sha256; cv=none; b=kPxPzMi1O6tDP2JRfF7OfIauQ3ZT2eV2KvFcpKmf+muLGdG871iMwb4TuUjGDkDTaFDZFU MTn6hxw7Y3tpNuQj694UQ55wkogitU75sLjwB2R5apX1YdphXfEy0Wsl+SWr1mu8gDGVh9 mty3W21Bc2gE16qrVzS1AbkCubqMEqk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=BY5dlkL5; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf10.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.119 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731404767; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RFjjREpMZxKxsiOJad01yhROc9AzNVhtqJ3oU5t0vhQ=; b=F0OVIYVZcEIvXEK+C02W4cyhvRSVVOAJQLwqiknOUTCYdxlwQlcBipN1GkCZjsI5Ih6qN/ XlT5AwgRTkD6ngp8JMDK6S/Oz/TjPeI1Uh0s4Mhfruo9UAXc39MB1F3KVQN00T6+r2haUY aFntXGR85cds97XROQ+mBBZwRZePjUM= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1731404824; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=RFjjREpMZxKxsiOJad01yhROc9AzNVhtqJ3oU5t0vhQ=; b=BY5dlkL5E5la6d5TE2LpQ5qf+H+mDIIlbmaf+HyGQcRDCjO8UbwSRqaK5EPM2zzZb/rRgNyA/Q4jZiZ+L4LrTQlB0qtDc8OE6UrHByBLoGZu24aNsKtOgtk2A8CKeEbsBj4ec3bX4WX5FeLNi844qXaODMsRh8AyeofeXu0e5NY= Received: from 30.74.144.120(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WJGy4ng_1731404822 cluster:ay36) by smtp.aliyun-inc.com; Tue, 12 Nov 2024 17:47:03 +0800 Message-ID: <2503b955-79a9-4d21-9a25-34a6c33e688d@linux.alibaba.com> Date: Tue, 12 Nov 2024 17:47:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/compaction: fix the total_isolated in strict mode To: "liuq131@chinatelecom.cn" , akpm Cc: linux-mm , linux-kernel References: <20241102201621.95291-1-liuq131@chinatelecom.cn> <055703d7-1434-42fb-8048-add21a9bd44c@linux.alibaba.com> <2024111210165296529720@chinatelecom.cn> From: Baolin Wang In-Reply-To: <2024111210165296529720@chinatelecom.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Queue-Id: 6AB27C0009 X-Rspamd-Server: rspam01 X-Stat-Signature: xs5yby1zhtucwqdas5hemgcku33q1qc5 X-HE-Tag: 1731404808-11587 X-HE-Meta: U2FsdGVkX19j/XrnwimttUlDr7llIsPVhERaK7w/ks3oJo5UCBp3c7WZRrH1iaRWNh2yxspwIsEJdFhkMa2vEV5fA5jZhIfgEJEZMh8nJlecsdkqEwIxlHaMDOK6njIXafIdR8ze2ipuT9zTP+HAGLybmoBsHNUux/ci+8ibhEp57WJ3Wh3vmkTMPEVtsGsJ2DOinR24aPf/n/31E/d0djsOMHQe37fGEtp2o/kRpBFR31qJFDJXx4q3zSiw2ESY0xReKqWbQW5hJI+jCy7xZ04poNMMyRiZNNJgK8kgADle5v10O9xEmQTpZDrJRgIrJ/2pFiDCJhMQOL3DJGuKTe6hL3gbou3DHXQk6uC+ESUDWlof/Ys/2s2Cyc7PKaMo8ZJwivB7EBBdZzapB0sF0tGX0ZVeW05APilCvlQ/cZ2/qV+7IoJqUyORuOo7IiC/z2s9MDVZJUkuZY0cvVBm0Mm3ZQJxnSsSzwH5zh0YS/BdrlW2L680yBKTiM6dQL+U6STBPNInSuXPqEY6AehEsrxmdAKFfOkJwz3Ie3E3vFlSjU/ORiewV63pICcXxB+H7mviHYUkWdbVIhzmP7EZYEGJv+zNkRO3XuJDJPH1m3dS8qqarA9ASNsJexfzP8lYx9I3jFKzN/2seAT4mT6D8yZ8xrGZWHAFc/sbV6CQ+t4RJo9kGxPgfq4+BRT2AiCF3hwrGAGJgpSA/sYZYCJFRL99TRFOW8pcwpru4SmeeCuCuLAOH/QkXMNrh4oAeT131LsUkV9LGerKxFUgHDdQpH66MAVNJ1HgYUDTNnQ2nuArMnz7fOf5ms3GhOGyPugu2NejhTrXtxedE6Vt8aqX2IawlScjK0RvXUwnTQtZfrTTr6HmevNeIcEZCeDWHsmkHhU/sqR4mEKBl0RHTAYVKFErbvt1SfuoKBN+VIDxLMiJpcbVmhUPcN3IZb6I1Dlkl2BhK08GhIEK/ofpXeM ypkwWZ59 pRvE819LsB7icnA3H74zmClqto65i6R2N2OznnG2+fs1SMF/6z8k2xS7QE2HdWRR4Vqbeufxnnu57AcHm/sJYZorl6rh4/+wjTcKCMomh3HfVIu68fBMDV3I6S8KZxgQqHqweZaU7HP8p3ZQzB1hBrBVeKkj/ucP7ns8eMz2uYlAZ1GCWjTMxuWQ6nvr+BOCgQz1gHyfRgusA6NFsT8DJ9jlx8VngzNyhmO3C61imUUx0FRRksaaViusCdod8SbYN7OHSWv2x/WfHPa44LDDLazIx1VXLoApbPGNikv0VkSOBQ8wiAD7abDFIXe552zja3Whxnongi8LZ/y/KPkbMFUiFTA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000657, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2024/11/12 10:16, liuq131@chinatelecom.cn wrote: > "We assume that the block we are currently processing is distributed as follows: > 0 1 2 511 > -------------------------------------------------- > | | | | > --------------------------------------------------- > Index 0 and 1 are both pages with an order of 0. > Index 2 has a bogus order (let's assume the order is 9). > When the for loop reaches index 2, it will enter the following code: > /* > * For compound pages such as THP and hugetlbfs, we can save > * potentially a lot of iterations if we skip them at once. > * The check is racy, but we can consider only valid values > * and the only danger is skipping too much. > */ > if (PageCompound(page)) { > const unsigned int order = compound_order(page); > if (blockpfn + (1UL << order) <= end_pfn) { > blockpfn += (1UL << order) - 1; > page += (1UL << order) - 1; > nr_scanned += (1UL << order) - 1; > } > goto isolate_fail; > } > > After exiting the for loop: > blockpfn =basepfn+ 2+2^9 = basepfn+514 > endpfn = basepfn +512 > total_isolated = 2 > nr_scanned = 514 In your case, the 'blockpfn' will not be updated to 'basepfn+514', because 'blockpfn + (1UL << order) > end_pfn', right? And remember the 'end_pfn' is the end of the pageblock. So I'm still confused about your case. Is this from code inspection? > /* > * Be careful to not go outside of the pageblock. > */ > if (unlikely(blockpfn > end_pfn)) > blockpfn = end_pfn; > > So this can happen > > /* > * If strict isolation is requested by CMA then check that all the > * pages requested were isolated. If there were any failures, 0 is > * returned and CMA will fail. > */ > if (strict && blockpfn < end_pfn) > total_isolated = 0; > > If processed according to the old code, it will not enter the if statement to reset total_isolated, but the correct handling is to reset total_isolated to 0. Please do not top-posting: " - Use interleaved ("inline") replies, which makes your response easier to read. (i.e. avoid top-posting -- the practice of putting your answer above the quoted text you are responding to.) For more details, see :ref:`Documentation/process/submitting-patches.rst `. "