Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1838869rwn; Fri, 9 Sep 2022 05:02:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR4BBgVZFh9hNBeLJMOkWIj/IDIy6G6ZWWlamsn9DVrGdCbXfxvTyLZUKX9KW80tewIOdbo6 X-Received: by 2002:a05:6a00:1a47:b0:52e:6a8c:5430 with SMTP id h7-20020a056a001a4700b0052e6a8c5430mr13824590pfv.48.1662724957036; Fri, 09 Sep 2022 05:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662724957; cv=none; d=google.com; s=arc-20160816; b=hVJvRPQqzp6JPIO6L6kUSWeg4edCVtBWqoiqX5bKHDD/0FhPQjykXyhSzn5GYsFrg8 a4cekG8Rm5Y3qkfTQ8bwUuyhbnw/3wY0gNQUPiWAfaOmbSi1lCHti7pdtsDjJLPnm5ol ZByIpupHSuR5FzWBq/6DzJGgmHv2InGx9kCbnNDLYPmwn6PQtYyx6G6xGTRCyA86Q0uU fHkEOA5TJgd2ZWRBnq49DlzGezBKtYux/uzFd0jBLPvfYfFA6lUODHWKqsXc6jZCfZHW 4Lv3ldUdaaXDNasvU+euhXXSZzj9d1WYzbdRA9CK3HdAvo8eRkTd2gfb5+K4fRs5Y5pR cf3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=zADjijewHqE/ifMUiS21SSfRedrzbyoD3zQRtee5o1s=; b=HUsKepiK/9c6nFNHf5pqMFSFxI7Obrw+ucJ/+81bdQDRWI9csLF31rI9z01yxLn7VA OFucS+cC/DpJJUDsUorFdDsC/1L1hD0nwVCB+/QJQyisNacD6DIFGnxJpVcFFHrOc2TM BKopjE37FVuK52qt+dez8oMZcP7IDJDXPuMsjGP3gHdAy29gkZarml0osNn0M0a2EGjS VoV+sW3mXHao2bjeevnQYSRr9Uh4beH3p8tqAZeMJZcFlilkafYOrgPoB+QVveWgJZzB KKPXtnBl4BZbw0fXq/cca5AuKzLEJwegV9H7ax03Hkd0AJpFa8nxPH506EFj1QoiSjF1 JcMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="aySK+C/C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a056a0023c500b0052b2d61f2c8si364007pfc.293.2022.09.09.05.02.16; Fri, 09 Sep 2022 05:02:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="aySK+C/C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbiIIL2w (ORCPT + 99 others); Fri, 9 Sep 2022 07:28:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230181AbiIIL2s (ORCPT ); Fri, 9 Sep 2022 07:28:48 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67CA113867C for ; Fri, 9 Sep 2022 04:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662722924; 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=zADjijewHqE/ifMUiS21SSfRedrzbyoD3zQRtee5o1s=; b=aySK+C/CSgOySxetymwlRu/ir9zIj/2RJoORs5rMhyz17r4jLnpENDt/DF2vsdLQETTfUP V7yNgiKKrkbZSj/GPnLEf0J+tkSqlM3i/V5dyfNnVqyYPdqWjCOHzT/rtz3VLXs3KsKGvp BCuhOSEQaw8Vf0OjMtSw0yeib9biiWk= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-190-LLctdqQjPJG4BjWT4BGsKg-1; Fri, 09 Sep 2022 07:28:43 -0400 X-MC-Unique: LLctdqQjPJG4BjWT4BGsKg-1 Received: by mail-wr1-f72.google.com with SMTP id v15-20020adf8b4f000000b002285ec61b3aso280482wra.6 for ; Fri, 09 Sep 2022 04:28:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=zADjijewHqE/ifMUiS21SSfRedrzbyoD3zQRtee5o1s=; b=7Fn66ngN1tIEYHuct+PifFmsp7YSlBlx7m8whio3i/ArX4J+myYt+57Nhj8lmfswc4 eIdUzicgt1owiGQLIqpKi6lm2mjqA9FJdeRo4mAu889Y76S8VLfdqwZYSiuMER69nmYv WmtMJ91keSurBLMin2CWKJ+4PnONgPFEG89vihNQVl76etd/DK9HtQBCjUqlFbNJVx3D a9V4N6MJ4QJIjgCV2ptM+5aDqeoX+ypNWWSZhTrQDQcrJrxxcyBsYeqK8qD/HBpi4Va6 8J5JZOkM0lcsXsmMcyacMJn6yzcAW5k4nToj5Cl/44uMVEyclFCR4pzUDf1ykKX6cy0Q DShA== X-Gm-Message-State: ACgBeo2Ykbnd+smiNNrIEwcHRlNIfSyQBRqn4OIIjHsHq9LnjQCCMsYI PpJjP2gh5w7EKottI4Ym1xLEVQkKwkCMWtHs5zd/V1KOV9fj8BasMcQNFvW5lDM/stFtpDPdgkx NT2J1ICKX3tT77xs3bpYYeYX9 X-Received: by 2002:adf:fb52:0:b0:225:2ada:b741 with SMTP id c18-20020adffb52000000b002252adab741mr7921755wrs.56.1662722922182; Fri, 09 Sep 2022 04:28:42 -0700 (PDT) X-Received: by 2002:adf:fb52:0:b0:225:2ada:b741 with SMTP id c18-20020adffb52000000b002252adab741mr7921748wrs.56.1662722921959; Fri, 09 Sep 2022 04:28:41 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:6300:1fe0:42e1:62c5:91b6? (p200300cbc70463001fe042e162c591b6.dip0.t-ipconnect.de. [2003:cb:c704:6300:1fe0:42e1:62c5:91b6]) by smtp.gmail.com with ESMTPSA id h17-20020a05600c2cb100b003a5ca627333sm467212wmc.8.2022.09.09.04.28.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Sep 2022 04:28:41 -0700 (PDT) Message-ID: <77c1ccc6-9125-ea91-45d8-7e087b38e196@redhat.com> Date: Fri, 9 Sep 2022 13:28:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH 06/16] mm/page_alloc: fix freeing static percpu memory Content-Language: en-US To: Miaohe Lin , akpm@linux-foundation.org Cc: osalvador@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220909092451.24883-1-linmiaohe@huawei.com> <20220909092451.24883-7-linmiaohe@huawei.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220909092451.24883-7-linmiaohe@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09.09.22 11:24, Miaohe Lin wrote: > The size of struct per_cpu_zonestat can be 0 on !SMP && !NUMA. In that > case, zone->per_cpu_zonestats will always equal to boot_zonestats. But > in zone_pcp_reset(), zone->per_cpu_zonestats is freed via free_percpu() > directly without checking against boot_zonestats first. boot_zonestats > will be released by free_percpu() unexpectedly. > > Fixes: 28f836b6777b ("mm/page_alloc: split per cpu page lists and zone stats") > Signed-off-by: Miaohe Lin > --- > mm/page_alloc.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3497919f4ef5..a35ef385d906 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -9510,9 +9510,11 @@ void zone_pcp_reset(struct zone *zone) > drain_zonestat(zone, pzstats); > } > free_percpu(zone->per_cpu_pageset); > - free_percpu(zone->per_cpu_zonestats); > zone->per_cpu_pageset = &boot_pageset; > - zone->per_cpu_zonestats = &boot_zonestats; > + if (zone->per_cpu_zonestats != &boot_zonestats) { > + free_percpu(zone->per_cpu_zonestats); > + zone->per_cpu_zonestats = &boot_zonestats; > + } > } > } > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb