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 12241C433EF for ; Tue, 31 May 2022 12:00:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CD1B6B0072; Tue, 31 May 2022 08:00:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 729B66B0073; Tue, 31 May 2022 08:00:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A1A16B0074; Tue, 31 May 2022 08:00:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4C68E6B0072 for ; Tue, 31 May 2022 08:00:00 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 053D612033F for ; Tue, 31 May 2022 12:00:00 +0000 (UTC) X-FDA: 79525894560.20.BA3ADE7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id A565E12005A for ; Tue, 31 May 2022 11:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653998399; h=from:from: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; bh=PGwek/6vdYkYYLHUigLW7HiiIxESVvwETc14ysV7hYY=; b=IJctP2Kl2eQLkDfIEuixupKVkzZ0yf17oZ/nEYYhqAZ676NP4e1b1K/f4IgwkbixiR+cK6 PVACWkhiAzN+Yao8N1t5CmFKuGMW86ofOiQl9WCewg/TNgndjf73jB6So88JybKrqvk2QS nQX2l27uIzpcQxql8QDtuPn0k9cVcF8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-75-SmthsgCqM5WKY8H_jJ8zIA-1; Tue, 31 May 2022 07:59:57 -0400 X-MC-Unique: SmthsgCqM5WKY8H_jJ8zIA-1 Received: by mail-wm1-f69.google.com with SMTP id l15-20020a05600c1d0f00b003973901d3b4so5935420wms.2 for ; Tue, 31 May 2022 04:59:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=PGwek/6vdYkYYLHUigLW7HiiIxESVvwETc14ysV7hYY=; b=8K0EfiukmQv6br98ZVZWlNPzN16m1GbgOyz7YJFSl0xtehGGjgaxTyH7mh8PkGpiaE QVQWg8GZLl6Fw9hd8D/7QcPrDoZXN+OneOLsE0FpKguXaIsjRQpgafgixYba0yBwVVdF 2E8umbhzLUPacLmuK1rA5lOJa/r/O+2eT0kPArwfI6u7GP/jkVanIxCCrQ6Gtnj6FVCU qrKI1dmzRqT2mPg3yyE1NLU1RNlDkUh4x2RHiL9LNLDR9MQQtlxLyZvP30UQZCI5g+py dpViT1XW8DrQMXIees/gwxai1Fi/1mdtOlnTfdhpyhUKMBcL0HJR9AfhMvQZFXldk0pZ lg9w== X-Gm-Message-State: AOAM532FRi6fXwnXwcz4fIp9oC45rhXxGqQ8DfJCXhqUobE2miMe0tpX bc1o5NWQXN20i7jXhQ8H0HH+7U2J9zrfvVuT1F5piy1lUzJtoy6+hh3IIwLfr+AsfsND3SC6Ezm ykLR/lJyINlc= X-Received: by 2002:a1c:6a14:0:b0:397:39c4:8ac2 with SMTP id f20-20020a1c6a14000000b0039739c48ac2mr23346014wmc.112.1653998396529; Tue, 31 May 2022 04:59:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMdOdk0HMKlG66DrDiEJOvRunHR/ODdsjln64gd3oH6mSJ68C7FmQc8Slv+Otr7kLBZxLG4A== X-Received: by 2002:a1c:6a14:0:b0:397:39c4:8ac2 with SMTP id f20-20020a1c6a14000000b0039739c48ac2mr23345999wmc.112.1653998396321; Tue, 31 May 2022 04:59:56 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:f100:8096:9368:ba52:a341? (p200300cbc708f10080969368ba52a341.dip0.t-ipconnect.de. [2003:cb:c708:f100:8096:9368:ba52:a341]) by smtp.gmail.com with ESMTPSA id q12-20020a5d574c000000b002102f90870esm7373917wrw.108.2022.05.31.04.59.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 May 2022 04:59:55 -0700 (PDT) Message-ID: <0724b4c4-15f6-e429-f945-f57c619c7270@redhat.com> Date: Tue, 31 May 2022 13:59:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v2 2/4] mm/migration: remove unneeded lock page and PageMovable check To: Miaohe Lin Cc: ying.huang@intel.com, hch@lst.de, dhowells@redhat.com, cl@linux.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, naoya.horiguchi@nec.com, Minchan Kim References: <20220425132723.34824-1-linmiaohe@huawei.com> <20220425132723.34824-3-linmiaohe@huawei.com> <525298ad-5e6a-2f8d-366d-4dcb7eebd093@redhat.com> <4cf144a9-fff5-d993-4fcb-7f2dfa6e71bb@redhat.com> <924de987-202b-a97e-e6d2-6bdab530f190@huawei.com> <025d0dc8-a446-b720-14a8-97c041055f48@huawei.com> <143ab5dd-85a9-3338-53b7-e46c9060b20e@redhat.com> <6ba7e2bd-28c1-53ff-a6b7-072c79714dee@huawei.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <6ba7e2bd-28c1-53ff-a6b7-072c79714dee@huawei.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A565E12005A X-Rspam-User: X-Stat-Signature: ex1trxto8o14px3h11uoaw77pn15e5bi Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IJctP2Kl; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf29.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1653998386-180726 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Sorry for the late reply, was on vacation. >>> >>> But for isolated page, PageLRU is cleared. So when the isolated page is released, __clear_page_lru_flags >>> won't be called. So we have to clear the PG_active and PG_unevictable here manully. So I think >>> this code block works. Or am I miss something again? >> >> Let's assume the following: page as freed by the owner and we enter >> unmap_and_move(). >> >> >> #1: enter unmap_and_move() // page_count is 1 >> #2: enter isolate_movable_page() // page_count is 1 >> #2: get_page_unless_zero() // page_count is now 2 >> #1: if (page_count(page) == 1) { // does not trigger >> #2: put_page(page); // page_count is now 1 >> #1: put_page(page); // page_count is now 0 -> freed >> >> >> #1 will trigger __put_page() -> __put_single_page() -> >> __page_cache_release() will not clear the flags because it's not an LRU >> page at that point in time, right (-> isolated)? > > Sorry, you're right. I thought the old page will be freed via putback_lru_page which will > set PageLRU back instead of put_page directly. So if the above race occurs, PG_active and > PG_unevictable will remain set while page goes to the buddy and check_free_page will complain > about it. But it seems this is never witnessed? Maybe a) we were lucky so far and didn't trigger it b) the whole code block is dead code because we are missing something c) we are missing something else :) > >> >> We did not run that code block that would clear PG_active and >> PG_unevictable. >> >> Which still leaves the questions: >> >> a) If PG_active and PG_unevictable was cleared, where? > > For LRU pages, PG_active and PG_unevictable are cleared via __page_cache_release. And for isolated > (LRU) pages, PG_active and PG_unevictable should be cleared ourselves? > >> b) Why is that code block that conditionally clears the flags of any >> value and why can't we simply drop it? >> > > To fix the issue, should we clear PG_active and PG_unevictable unconditionally here? I wonder if we should simply teach actual freeing code to simply clear both flags when freeing an isolated page? IOW, to detect "isolated LRU" is getting freed and fixup? -- Thanks, David / dhildenb