Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10087052pxu; Tue, 29 Dec 2020 13:25:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzegSaQHAcoO0Rn/Lx7JmpfzcT79GguEZHavc0UOWD8ldRn8HaHwOiyfo9nr7gtBAaQKJ5g X-Received: by 2002:a05:6402:13d1:: with SMTP id a17mr47423476edx.202.1609277138820; Tue, 29 Dec 2020 13:25:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609277138; cv=none; d=google.com; s=arc-20160816; b=BjsDJV36sfRZSWTubVaBDAP9fZsUtMfVIJZGZlR+f7ZFSkCb46TXK5a6BTS4I1ih/M QZWZPPCQ6pmnp0lUvs8Molu8uy8L8h5fOpMcBS7txjEw1Zc94iGFYiU0/xd6yKF3y+7Z d6IFGjB3GdX2If5iF6vX71ZJYzL8icZ9gelkweoJ3og5FQ6odWprngaQ8IKFkcY0G1sk eRb2WC0ikrnsmzE5XYGJ98S/TdxKqATwe9P+NwxbxeGokEpsVEseXNecZ+orpAlNWjDh 4SsD8ceXFyO/DkeLCHbcIrjJtaFj/LVfB8ZJHfhwxPXTWVrhjs65+1JWzchxJWVw68+H IdfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=+MkqAKBq3A/knAAU13Gxz2RdEEHZpALwXvOrL0D2tVU=; b=wmS961JggIm5yMrDU5CU17nmE8z1ky7sNV87zSd2gaBJoxBvgZRF8wK5WfJIfZ9JjK HRjR9a823VpkS2by3T7VFDg4UnnN1KM2a7CwZb2I+dSqDaPsWVIkUpO7Z7DVXWXBguU+ oo7xl2nVVXbVYcOW5bXly01iiVUai9xjPVHkWQKoL9qRfchpKFg/z0s8TSZp+0FwCzSF Vt29ouUERkKo1FQS+Cw5b0UDPY3InKu6Cmynx8uU7tmHNoDLxNzD0Q6OJIShJ439y77U HLI0LcfOI+Nq9sj2d0DTv64emGUonbpQrkKDmyCjEWrEbz1lt7Yb6Q1zllFeVIj8XRYF HJaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=lzoh8IKg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx7si13719286ejb.280.2020.12.29.13.25.15; Tue, 29 Dec 2020 13:25:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=lzoh8IKg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726314AbgL2VYd (ORCPT + 99 others); Tue, 29 Dec 2020 16:24:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:36386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726242AbgL2VYc (ORCPT ); Tue, 29 Dec 2020 16:24:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E96FB2074B; Tue, 29 Dec 2020 21:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1609277032; bh=RxQOQuf1Y+ttZzPNxwEdSK4WRKnL6B6y/lEz6gysaUA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lzoh8IKgzoFFAs+0T/a7Yr+aA2fYNzSEUOgK43NfytqD5LjxvCjmnJdtPC9M7B3V1 keLX6X2QKaQ6SgCtbr728CYh5HB/BtyVjXiIShy2J07n5Sa566lJsLTcT6n5aPKcTo QbwcHoE8HfioRMEIkyjJhd9FD0iVgDdT/rC9FhfA= Date: Tue, 29 Dec 2020 13:23:51 -0800 From: Andrew Morton To: Hailong liu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, liu.hailong6@zte.com.cn Subject: Re: [PATCH] mm/page_alloc:add a missing mm_page_alloc_zone_locked tracepoint Message-Id: <20201229132351.025362ec38b0a763340a82de@linux-foundation.org> In-Reply-To: <20201228132901.41523-1-carver4lio@163.com> References: <20201228132901.41523-1-carver4lio@163.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Dec 2020 21:29:01 +0800 Hailong liu wrote: > The trace point *trace_mm_page_alloc_zone_locked()* in __rmqueue() does not > currently cover all branches. Add the missing tracepoint and check the page > before do that. > > ... > > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -2871,7 +2871,7 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, > zone_page_state(zone, NR_FREE_PAGES) / 2) { > page = __rmqueue_cma_fallback(zone, order); > if (page) > - return page; > + goto out; > } > #endif > retry: > @@ -2884,8 +2884,9 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, > alloc_flags)) > goto retry; > } > - > - trace_mm_page_alloc_zone_locked(page, order, migratetype); > +out: > + if (page) > + trace_mm_page_alloc_zone_locked(page, order, migratetype); > return page; > } Looks right to me, but it generates a warning. Using IS_ENABLED() works around it. From: Andrew Morton Subject: mm-page_alloc-add-a-missing-mm_page_alloc_zone_locked-tracepoint-fix use IS_ENABLED() to suppress warning mm/page_alloc.c: In function ‘__rmqueue’: mm/page_alloc.c:2889:1: warning: label ‘out’ defined but not used [-Wunused-label] out: ^~~ Cc: Hailong liu Signed-off-by: Andrew Morton --- mm/page_alloc.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) --- a/mm/page_alloc.c~mm-page_alloc-add-a-missing-mm_page_alloc_zone_locked-tracepoint-fix +++ a/mm/page_alloc.c @@ -2862,20 +2862,20 @@ __rmqueue(struct zone *zone, unsigned in { struct page *page; -#ifdef CONFIG_CMA - /* - * Balance movable allocations between regular and CMA areas by - * allocating from CMA when over half of the zone's free memory - * is in the CMA area. - */ - if (alloc_flags & ALLOC_CMA && - zone_page_state(zone, NR_FREE_CMA_PAGES) > - zone_page_state(zone, NR_FREE_PAGES) / 2) { - page = __rmqueue_cma_fallback(zone, order); - if (page) - goto out; + if (IS_ENABLED(CONFIG_CMA)) { + /* + * Balance movable allocations between regular and CMA areas by + * allocating from CMA when over half of the zone's free memory + * is in the CMA area. + */ + if (alloc_flags & ALLOC_CMA && + zone_page_state(zone, NR_FREE_CMA_PAGES) > + zone_page_state(zone, NR_FREE_PAGES) / 2) { + page = __rmqueue_cma_fallback(zone, order); + if (page) + goto out; + } } -#endif retry: page = __rmqueue_smallest(zone, order, migratetype); if (unlikely(!page)) { _