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 48925C433F5 for ; Thu, 14 Apr 2022 14:02:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAB296B0071; Thu, 14 Apr 2022 10:02:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5AF46B0073; Thu, 14 Apr 2022 10:02:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FC536B0074; Thu, 14 Apr 2022 10:02:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 8DCF86B0071 for ; Thu, 14 Apr 2022 10:02:47 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 672D96306E for ; Thu, 14 Apr 2022 14:02:47 +0000 (UTC) X-FDA: 79355650374.17.2705350 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id CA33C40027 for ; Thu, 14 Apr 2022 14:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649944956; 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=r1AnOH9s7DSYL3vteuGfJhK0BPbgyTYHpqqRt2VurCg=; b=d9Z9QK4cqrRx9QlJMA0r7MGa4L/J25J8w88PwGyVKPVuZETY8CyuWr/0tJcUFU//LNfS9g wvU5Pk8d4ywnmJ272mb9CUa1J2v3DF+sLKZ2JGbLITt76uF9DwarX8tJNn96oG4krXja7x v1JqEgOBoqaI8ijWuqKwVR3KAD6OaAQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649944964; 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=r1AnOH9s7DSYL3vteuGfJhK0BPbgyTYHpqqRt2VurCg=; b=F01r0YQjQ21UUtGyRnBMQsDoWtgF25HOrUiX0DkjdxpnQuzrbviNN0hTvQwqof0Zq1PaGp sz5/F/toQKBXOk7mSiEP3ug49P4gueife/83/ut/SyD743QhV4N9YYpPFmxmxj8hmT0qar BucfY3CbLVjRvFmW5Odrn8KeZgoC3dk= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-259-TsH56SuHMsW0p8CTSr2A3g-1; Thu, 14 Apr 2022 10:02:34 -0400 X-MC-Unique: TsH56SuHMsW0p8CTSr2A3g-1 Received: by mail-wr1-f71.google.com with SMTP id q4-20020adfc504000000b002079c9cc1bfso854174wrf.11 for ; Thu, 14 Apr 2022 07:02:34 -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=r1AnOH9s7DSYL3vteuGfJhK0BPbgyTYHpqqRt2VurCg=; b=RusxBmv3003di+qPgzs1dCfz0w75CG2te5RQo+/r2x2zxJQREB2mPamOs7AzdcpQB6 osYf2JGuW0U/xU03O34nsFwYNfTrWm6UX5hgTwbuv1TnxBNtul+F3n/b7siOzyWjdKTt anjMTF+MWxaYlC2HYXUqpKud/pKTsx1QiRCgEm+o+YmuUip/+//T0SEu5eWnDOtgfnde MJDqoZZ0i/GPr/UJcUy+xG6aInC6GGXOlpj+VLNht9CTkpxHVo6QHYnEebmDcDw71Wxp fEGIWo86b3XkDQIa+Fqr/pSVVf5ynX8iQwMcY6ws6NGVvlrGm7d6t9ECZpibeMmxi2vB XirA== X-Gm-Message-State: AOAM530LgGyep7NKhQi/KqvnRxorTnG0zgQS9ecjx2vc8RCnSzSLr8XR Gj2WP41o8WCrgK+G0TGnD8dOiDEQ06K8o+SUCqUzPUcTiB0D0Rnf4CtZx4CAZ+NSGb73QYwo/zr AizmV8O4PVXc= X-Received: by 2002:adf:e3c8:0:b0:207:a128:6205 with SMTP id k8-20020adfe3c8000000b00207a1286205mr2158349wrm.370.1649944953587; Thu, 14 Apr 2022 07:02:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCOLeKlyEqyoNtDnsf/KJBwbDMTg1Ighp92mVOoajOu0oPWOYLt1ASMLPz3qkqj3C5XmDGBA== X-Received: by 2002:adf:e3c8:0:b0:207:a128:6205 with SMTP id k8-20020adfe3c8000000b00207a1286205mr2158327wrm.370.1649944953315; Thu, 14 Apr 2022 07:02:33 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:20af:34be:985b:b6c8? ([2a09:80c0:192:0:20af:34be:985b:b6c8]) by smtp.gmail.com with ESMTPSA id i5-20020adfb645000000b002060e559f24sm1858050wre.92.2022.04.14.07.02.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Apr 2022 07:02:32 -0700 (PDT) Message-ID: <91b35970-b68e-580f-b17d-789fcc2e1c47@redhat.com> Date: Thu, 14 Apr 2022 16:02:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH] mm, page_alloc: check pfn is valid before moving to freelist To: Mike Rapoport , David Rientjes Cc: Andrew Morton , Sudarshan Rajagopalan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Anshuman Khandual , Suren Baghdasaryan References: <20220412135912.93175db2ab4e83f4bb060dbf@linux-foundation.org> <6daaaf5c-529d-f3eb-7486-a72cabb6e396@google.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: 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-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=d9Z9QK4c; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=F01r0YQj; spf=none (imf12.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CA33C40027 X-Stat-Signature: o67yi37mceac48znfcqb3n9egau8geqd X-HE-Tag: 1649944964-730414 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: On 13.04.22 22:55, Mike Rapoport wrote: > On Tue, Apr 12, 2022 at 02:05:51PM -0700, David Rientjes wrote: >> On Tue, 12 Apr 2022, Andrew Morton wrote: >> >>> On Tue, 12 Apr 2022 13:16:23 -0700 Sudarshan Rajagopalan wrote: >>> >>>> Check if pfn is valid before or not before moving it to freelist. >>>> >>>> There are possible scenario where a pageblock can have partial physical >>>> hole and partial part of System RAM. This happens when base address in RAM >>>> partition table is not aligned to pageblock size. >>>> >>>> ... >>>> >>>> >>>> Signed-off-by: Sudarshan Rajagopalan >>>> Fixes: 4c7b9896621be ("mm: remove pfn_valid_within() and CONFIG_HOLES_IN_ZONE") >>> >>> I made that 859a85ddf90e714092dea71a0e54c7b9896621be and added >>> cc:stable. I'll await reviewer input before proceeding further. >>> >> >> Acked-by: David Rientjes >> >>>> --- a/mm/page_alloc.c >>>> +++ b/mm/page_alloc.c >>>> @@ -2521,6 +2521,11 @@ static int move_freepages(struct zone *zone, >>>> int pages_moved = 0; >>>> >>>> for (pfn = start_pfn; pfn <= end_pfn;) { >>>> + if (!pfn_valid(pfn)) { >>> >>> Readers will wonder how we can encounter an invalid pfn here. A small >>> comment might help clue them in. >>> >> >> Sudarshan can correct me if I'm wrong, but this has to do with the >> pageblock alignment of the caller that assumes all pages in the range has >> an underlying struct page that we can access but that fails to hold true >> when we have a memory hole. A comment would definitely help: > > We do have a struct page for every page in a pageblock even if there is a > hole in the physical memory. If this is not the case, there is more > fundamental bug that should be fixed. Also, I dislike handling such a corner case in a way that affects all other sane cases. move_freepages() is also used for page isolation. I agree that this should be fixed differently, if possible. -- Thanks, David / dhildenb