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 211B6C433EF for ; Wed, 6 Oct 2021 12:18:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B6E6D61165 for ; Wed, 6 Oct 2021 12:18:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B6E6D61165 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 4ED5F6B0071; Wed, 6 Oct 2021 08:18:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49D4B6B0073; Wed, 6 Oct 2021 08:18:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 364A2940007; Wed, 6 Oct 2021 08:18:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id 277D56B0071 for ; Wed, 6 Oct 2021 08:18:50 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D1E01181FA8AA for ; Wed, 6 Oct 2021 12:18:49 +0000 (UTC) X-FDA: 78665916378.38.99FF506 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 6865CD038665 for ; Wed, 6 Oct 2021 12:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633522729; 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=oeW4XUXFrLRRjkI5JwIeK/O8BTLACXNB4vxVnuS9PKM=; b=QTjLMrr7CdrawHAzx8ks3rhqzt71mtOyguEp+8mBSHYFvyuvm8kZtZKOAs+W3M8KTjumSR 0ZGN8mn0mG7O2JimN64EE0e3veACEMMK6/JmZQqrxaSZFLijMsBOO3IOmNLvMEyHPm4MgN 6/9/m1FjRIYu4o1ESuOxAxv2SDENKvA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-x0TBNCBeMcahazuZmjmA2A-1; Wed, 06 Oct 2021 08:18:48 -0400 X-MC-Unique: x0TBNCBeMcahazuZmjmA2A-1 Received: by mail-wr1-f72.google.com with SMTP id k2-20020adfc702000000b0016006b2da9bso1881631wrg.1 for ; Wed, 06 Oct 2021 05:18:47 -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=oeW4XUXFrLRRjkI5JwIeK/O8BTLACXNB4vxVnuS9PKM=; b=JRpm8sGPqDBk08QaSYQLRMyn8rGWCD+SIH3mmZDNR5g9MGQw4hseA6gYjMfBLgg7At J0VN3QvENEabgJ6UlJfysFgwQvwNudnwEWf+36SXTisd3S1Y6sXfLTtrOuF2gtkXDvXg 0Md3/P6dbUjvEGlDAn70KEOwaoTQy265IQreTau/s+KeFz8QUTL5HaLBzM2rgC/5eXCh bW+TD+8Mx0VKHx45FCauZxn1MsvoPcGx9iK5FN2rEJJlWouaFMpSjqg9Aszgrsz+SEY/ AWzPWvmB/lhVOfCfoNrqNmZpT5yppRK8eA6Ad3M4tKoxOuDvhUcXso2ZCD59Rj2x8ux2 4sKw== X-Gm-Message-State: AOAM531cpv2bpSh0fkbXujTP8c70UegwakVOmB1aK/4v9EwmE111IDye 6WaG4IKLsGa/GTkqnqaDddH8vC9hg3Q6P0SaGc9u+V4VjiB82+lYdXtoLjSbov6Ilqpzz9q8kZZ kQquZr/jPWtM= X-Received: by 2002:a1c:1f86:: with SMTP id f128mr9428555wmf.124.1633522726797; Wed, 06 Oct 2021 05:18:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxflITgygSizV1S+GboAVyuNdISDFKtTP9efFwWM5U8Gz4Tu3T997UtGlecOp0W0idpvdKhQw== X-Received: by 2002:a1c:1f86:: with SMTP id f128mr9428533wmf.124.1633522726600; Wed, 06 Oct 2021 05:18:46 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6529.dip0.t-ipconnect.de. [91.12.101.41]) by smtp.gmail.com with ESMTPSA id l17sm20842009wrx.24.2021.10.06.05.18.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Oct 2021 05:18:46 -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> <88df48af-901b-5765-d92c-6d14c2b1f73e@codeaurora.org> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Wed, 6 Oct 2021 14:18:45 +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: <88df48af-901b-5765-d92c-6d14c2b1f73e@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 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6865CD038665 X-Stat-Signature: 11yd5hucu5t3a8eih5txta1z14kpgpsz Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QTjLMrr7; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf21.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1633522729-60136 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 06.10.21 14:13, Faiyaz Mohammed wrote: > Hi, >=20 > Sorry for delayed response. >=20 > On 9/29/2021 10:33 PM, David Hildenbrand wrote: >> On 29.09.21 10:58, Faiyaz Mohammed wrote: >>> >>> >>> 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_reser= ve" >>>>>>> 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-0x= 00000083603000] >>>>>>> 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-0x= 00000081a00000] >>>>>>> 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=C2=A0 mm/page_alloc.c | 5 +++++ >>>>>>> =C2=A0=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 *sta= rt, >>>>>>> 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=C2=A0= pr_info("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=C2=A0 s, pages << (PAGE_SHIFT - 10)); >>>>>>> =C2=A0=C2=A0=C2=A0 +#ifdef CONFIG_HAVE_MEMBLOCK >>>>>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 memblock_dbg("membloc= k_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 alloca= ted >>>>>> early via memblock, then we transitioned to the buddy, now we're >>>>>> freeing >>>>>> 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, >> memblock_free", when memblock might no longer be around. We have other >> places where we free early memblock allocations back to the buddy. > I didn't find place where we free early memblock allocation back to the > buddy. One example I know is section_deactivate()->free_map_bootmem()->vmemmap_free()-> ...=20 free_pagetable()->free_reserved_page(). when we free the vmemmap allocated via memblock back to the buddy. >=20 > Why "memblock_dbg" print with "memblock_free" string?. > - After buddy took over, buddy will free memblock reserved memory > through free_reserved_area and it will print the freed memory size, but > the freed memory through buddy still be part of memblock.reserved.regio= ns. > - To know the address ranges, added the "memblock_dbg" print along with > "membloc_free" string. > - If it is misleading or confusing, we can remove the "memblock_free" > string from the "memblock_dgb" print and we can just print the address > range when "memlock=3Ddebug" pass through command line. That would be better, but do we really have to depend on=20 "memlock=3Ddebug"? Can't we do pr_debug() ? --=20 Thanks, David / dhildenb