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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDE60C433EF for ; Wed, 29 Sep 2021 17:03:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 774F66124B for ; Wed, 29 Sep 2021 17:03:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 774F66124B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 11FBB940047; Wed, 29 Sep 2021 13:03:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D04B94003A; Wed, 29 Sep 2021 13:03:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED944940047; Wed, 29 Sep 2021 13:03:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id DF9C894003A for ; Wed, 29 Sep 2021 13:03:55 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7D81939F55 for ; Wed, 29 Sep 2021 17:03:55 +0000 (UTC) X-FDA: 78641233230.09.A0032CA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 29F7FD000646 for ; Wed, 29 Sep 2021 17:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632935034; 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=hTE5zFleGLnTuyLrFqdFPMU22BAwoJNwUb4warb1Xi4=; b=XCmS5QXOna/fo3c3BLu8WIZZAC60SDfXCdspTe1Cy6nJLp0zaYqrFPPy9ewcOOYR/SesJa 7tu3u9X92YzNotctq5CCEY8jWFjGkzI7IlBCbrMj30LzfsdJOdJSsCv8SB+q8TInSfUjE0 E6YLGIGmTt0dQeiFIOsfW4oCp0YaFHw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-323-JcNVl9djMheEXNQ96JcmMQ-1; Wed, 29 Sep 2021 13:03:53 -0400 X-MC-Unique: JcNVl9djMheEXNQ96JcmMQ-1 Received: by mail-wm1-f71.google.com with SMTP id r66-20020a1c4445000000b0030cf0c97157so1528366wma.1 for ; Wed, 29 Sep 2021 10:03:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=hTE5zFleGLnTuyLrFqdFPMU22BAwoJNwUb4warb1Xi4=; b=ZYKjtco3oarsr15ce3c+xhnIIn+i+HHTVHvXAt2M6b8DES+QCiw6+HpFFWDLmSCR69 jNnRmpi74wWYYyaDF8z1gqPAViTQbRVNwmg+sfDbp+EvG5xgAzGP/Z8jL2O2PBgfyS8H FxuggHi/l1MQTn2I1NSqUG2NWm5hz/krr852hzdSnMBjK5rZKA2PzUG00H9lHV9C9KvW 8oNzU0KfsRrglH6DFChKQL4zeHT4uWPX/DYc7SPWg29tZojufWM/SnMsecRIzegi9lum S8Nqv+CR5ju49COZ5iIOEweIsl09BRjXGTphnTW+aA8GltNbMEAVlK/zV6YoAZAYWtKP KYAw== X-Gm-Message-State: AOAM5308+wzZaJvSA1e6h5smCS43AsXKC7BDjuKEN8tw43wpsoD0zCJU X5aSZU2tKU5sCwYnhZPcg3pzTfidxbrwbcnan9JlF6g9YkURb0x7HkIDm1Io0d7jhLPgTv84y3X vFLjR94Yesqw= X-Received: by 2002:a05:600c:3b26:: with SMTP id m38mr1065218wms.176.1632935031977; Wed, 29 Sep 2021 10:03:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFT3c0vb/qzy1G4SkbQIPZPlSnrPV+5jondgwEWp4VtQKpRxeIjZOjfnGgAlQfz4Cp6i/4Yw== X-Received: by 2002:a05:600c:3b26:: with SMTP id m38mr1065198wms.176.1632935031786; Wed, 29 Sep 2021 10:03:51 -0700 (PDT) Received: from [192.168.3.132] (p4ff23c3b.dip0.t-ipconnect.de. [79.242.60.59]) by smtp.gmail.com with ESMTPSA id o15sm372589wmc.21.2021.09.29.10.03.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Sep 2021 10:03:51 -0700 (PDT) Subject: Re: [PATCH v1] mm: page_alloc: Add debug log in free_reserved_area for static memory To: Faiyaz Mohammed , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: guptap@codeaurora.org References: <1632819849-511-1-git-send-email-faiyazm@codeaurora.org> <248ec931-7c16-3e2d-cc8f-8ce0dd4e923b@redhat.com> <0149edd5-fe7f-2786-413c-6de2eab3e30c@codeaurora.org> <1f6708d2-1ca8-6d1f-d9f0-855f2df755ed@codeaurora.org> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Wed, 29 Sep 2021 19:03:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1f6708d2-1ca8-6d1f-d9f0-855f2df755ed@codeaurora.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XCmS5QXO; spf=none (imf20.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 29F7FD000646 X-Stat-Signature: r66eczyy65hzmkyoq8ag1i61ugyhcgjg X-HE-Tag: 1632935035-985218 Content-Transfer-Encoding: quoted-printable 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 29.09.21 10:58, Faiyaz Mohammed wrote: >=20 >=20 > On 9/28/2021 4:46 PM, David Hildenbrand wrote: >> On 28.09.21 12:53, Faiyaz Mohammed wrote: >>> >>> >>> On 9/28/2021 4:09 PM, David Hildenbrand wrote: >>>> On 28.09.21 11:04, Faiyaz Mohammed wrote: >>>>> For INITRD and initmem memory is reserved through "memblock_reserve= " >>>>> during boot up but it is free via "free_reserved_area" instead >>>>> of "memblock_free". >>>>> For example: >>>>> [=C2=A0=C2=A0=C2=A0 0.294848] Freeing initrd memory: 12K. >>>>> [=C2=A0=C2=A0=C2=A0 0.696688] Freeing unused kernel memory: 4096K. >>>>> >>>>> To get the start and end address of the above freed memory and to >>>>> account >>>>> proper memblock added memblock_dbg log in "free_reserved_area". >>>>> After adding log: >>>>> [=C2=A0=C2=A0=C2=A0 0.294837] memblock_free: [0x00000083600000-0x00= 000083603000] >>>>> free_initrd_mem+0x20/0x28 >>>>> [=C2=A0=C2=A0=C2=A0 0.294848] Freeing initrd memory: 12K. >>>>> [=C2=A0=C2=A0=C2=A0 0.695246] memblock_free: [0x00000081600000-0x00= 000081a00000] >>>>> free_initmem+0x70/0xc8 >>>>> [=C2=A0=C2=A0=C2=A0 0.696688] Freeing unused kernel memory: 4096K. >>>>> >>>>> Signed-off-by: Faiyaz Mohammed >>>>> --- >>>>> =C2=A0=C2=A0 mm/page_alloc.c | 5 +++++ >>>>> =C2=A0=C2=A0 1 file changed, 5 insertions(+) >>>>> >>>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >>>>> index b37435c..f85c3b2 100644 >>>>> --- a/mm/page_alloc.c >>>>> +++ b/mm/page_alloc.c >>>>> @@ -8129,6 +8129,11 @@ unsigned long free_reserved_area(void *start= , >>>>> void *end, int poison, const char >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pr_in= fo("Freeing %s memory: %ldK\n", >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 s, pages << (PAGE_SHIFT - 10)); >>>>> =C2=A0=C2=A0 +#ifdef CONFIG_HAVE_MEMBLOCK >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 memblock_dbg("memblock_= free: [%#016llx-%#016llx] %pS\n", >>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= __pa(start), __pa(end), (void *)_RET_IP_); >>>>> +#endif >>>> >>>> IMHO, the "memblock_free" part is misleading. Something was allocate= d >>>> early via memblock, then we transitioned to the buddy, now we're fre= eing >>>> that early allocation via the buddy. >>>> Yes, we're freeing the early allocation via buddy, but for proper >>> memblock accounting we need this debug print. >>> >> >> What do you mean with "accounting" ? These are debug statements. >> >> > Yes, these are debug statements, which help to know the a-b address > belongs to x callsite. This info is required when memblock=3Ddebug is > passed through command line and CONFIG_HAVE_MEMBLOCK is enabled. The issue I'm having is talking in the name of memblock "memblock_dbg,=20 memblock_free", when memblock might no longer be around. We have other=20 places where we free early memblock allocations back to the buddy. --=20 Thanks, David / dhildenb