From patchwork Fri Jul 21 13:17:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 123850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp208779vqg; Fri, 21 Jul 2023 06:33:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlF3vxV7qsWPh9Ud6cpQ9JbBL8XqJg3fkqt4JkEZAgpfFQRfPpMgTFtiJK4On6NJvOJ+jMvs X-Received: by 2002:a17:902:b083:b0:1b1:9d43:ad4c with SMTP id p3-20020a170902b08300b001b19d43ad4cmr1507283plr.40.1689946421364; Fri, 21 Jul 2023 06:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689946421; cv=none; d=google.com; s=arc-20160816; b=rAU9Ih7IxKoTkpVtn0l5/tOKXzYhgffLPCV2J+c9i+7zEcI5rJnVSwiGgY+XFbNvjK fwj4k7F0esu3Lt6u2UPM/QjActs3xR1lUQwNgB1zRQoFPsIxs4zsL/VYiPyfSd7nJ/1W GtQIJcy1CVudLzGMgkzUM/CXU1Hg6nPDp/uoQ3CfiMFh1pYJe4OT80ANlYMfIe5Tw9E1 K/bH+ymPIB8PdOC3kpCMPfhOhilMyJ+I34fm6ZOIWS8+D5AaNBo5F337BjFXsej2KsUR 1F8uk2lr8Me3494Pi+ec7K3HYxR59GuPWEE9QB5qOlvlm4P2CMoDUGq6jsmqBVu1azuv n77A== 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:date:subject:cc:to:from :dkim-signature; bh=+qYMYKznWRCQRLs4itQFPGrBm6WN+EZaQC54fSpIxmA=; fh=Co6b409Lrw+DmjUOZ9t4Bt8msCZwijfEojhQPoEHRbo=; b=czy3CXXln7tZ38KdD/fPSSsoKcZrmDAT+RbtWSlIah8xTEFVt/ERaI4RTvdSbSMGO3 IDr/ip/6vZcnbBnnBESx0zk6K0D6JE64RwwP25HOFHrGIFKGyn0dd9uh9NRxz8OqoXT7 HEygB8cbGqDiqlxTLQOK4whezdfulYgmN1ahlExPfD87W8gRXRygnd2lEDDPDr7dpwsd d5zKNjNixB1rYJ8eKpDmi1dbx+2JjiOdwF6ZWIs8VgrBCpBjMA8OnzLE51SWGeSZw682 m0E54z3ectts8pSi3TMn4mtxXsXMbbQs2W3xouGdn7pdbciVwJeDQ9sW5/DHLm6bYRwV oGEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FTHaymwQ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id la5-20020a170902fa0500b001b9d5fb7fc8si2952064plb.101.2023.07.21.06.33.28; Fri, 21 Jul 2023 06:33:41 -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=FTHaymwQ; 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 S230373AbjGUNTG (ORCPT + 99 others); Fri, 21 Jul 2023 09:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbjGUNTD (ORCPT ); Fri, 21 Jul 2023 09:19:03 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C780930CF for ; Fri, 21 Jul 2023 06:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689945496; 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=+qYMYKznWRCQRLs4itQFPGrBm6WN+EZaQC54fSpIxmA=; b=FTHaymwQzF2Qk9EwNilR3ERghSd0wsRO2bGEq3Jvwm7TdB7s8prLZYBALLbegbyToWui3o DNGwovFA87Gp6FbChE1caTSp3B2C7ewXesG2rR5f8iZPYAREMllz9WqVH/7mKU1UGqgCln JlIUSlq8NCIT8XKvdFU9lAOvbZyyhQI= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-617-zn0bPHkSOBi7QroqT667-g-1; Fri, 21 Jul 2023 09:18:13 -0400 X-MC-Unique: zn0bPHkSOBi7QroqT667-g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C24F71C05154; Fri, 21 Jul 2023 13:18:12 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-18.pek2.redhat.com [10.72.12.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0A2C40C2071; Fri, 21 Jul 2023 13:18:08 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mawupeng1@huawei.com, Baoquan He Subject: [PATCH 1/3] mm/percpu.c: remove redundant check Date: Fri, 21 Jul 2023 21:17:58 +0800 Message-Id: <20230721131800.20003-2-bhe@redhat.com> In-Reply-To: <20230721131800.20003-1-bhe@redhat.com> References: <20230721131800.20003-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772037258805592843 X-GMAIL-MSGID: 1772037258805592843 The conditional check "(ai->dyn_size < PERCPU_DYNAMIC_EARLY_SIZE) has covered the check '(!ai->dyn_size)'. Signed-off-by: Baoquan He Acked-by: Dennis Zhou --- mm/percpu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/percpu.c b/mm/percpu.c index 28e07ede46f6..1480bf283d11 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2615,7 +2615,6 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, PCPU_SETUP_BUG_ON(ai->unit_size < PCPU_MIN_UNIT_SIZE); PCPU_SETUP_BUG_ON(!IS_ALIGNED(ai->unit_size, PCPU_BITMAP_BLOCK_SIZE)); PCPU_SETUP_BUG_ON(ai->dyn_size < PERCPU_DYNAMIC_EARLY_SIZE); - PCPU_SETUP_BUG_ON(!ai->dyn_size); PCPU_SETUP_BUG_ON(!IS_ALIGNED(ai->reserved_size, PCPU_MIN_ALLOC_SIZE)); PCPU_SETUP_BUG_ON(!(IS_ALIGNED(PCPU_BITMAP_BLOCK_SIZE, PAGE_SIZE) || IS_ALIGNED(PAGE_SIZE, PCPU_BITMAP_BLOCK_SIZE))); From patchwork Fri Jul 21 13:17:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 123858 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp216705vqg; Fri, 21 Jul 2023 06:47:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBQw5Qj7qcZ6SwqBqRnMWiURQGcSLk5VSBXVAd91fz+Q08AXwrkQFdro9OVeQI0szEMW84 X-Received: by 2002:a17:906:7a57:b0:983:cb6c:8aa3 with SMTP id i23-20020a1709067a5700b00983cb6c8aa3mr1750145ejo.59.1689947236731; Fri, 21 Jul 2023 06:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689947236; cv=none; d=google.com; s=arc-20160816; b=KOtGNJYk0hk31VGykotH9tk/vAPWzuqBRrBvbonwkyHpVOdPbWWdp8CdY4QTmCDlYv 1eqwTp0xJlNcrTnWBOZe9mkYcdlRHuWVK91UBonvey/vhufQXzW0Nvg1/OwRIvwdxbfV iQLUgnJGZ61dfHHGiYsC2sKSk+sm0CDMc3BCM9jAnLPF+ZKlJyMIKVdvHj8onBh+jkGL nx8Pt1jAiDSxaGvHWELjucSHAh2JWSIsdELlDdR/T3PrlhZnYqTfqje3ljsp1q9R6T21 BbftiWDlkTfZ3j5VoAll1vCfXlkyQNT0R5kBZGbDtd4TBXhTB8kW6S0GehFhOMREA767 6GwA== 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:date:subject:cc:to:from :dkim-signature; bh=LHVCmyopA5Gpa/p3+Tf6DYpT7yyPaihL3mV5AOHJdCk=; fh=Co6b409Lrw+DmjUOZ9t4Bt8msCZwijfEojhQPoEHRbo=; b=rrrSpMeH7GogK6w+V5s2g1kN+MZq4Fpsq+Pki9iumh5ypsKccbDkodHIJ8c/+240ex qQtVNhGGTOA+h9PiYAFnXvkvnfq9Qq6CccOzcIQZrbzzV4tk6xmjWWznzvksBnarnUV7 PBE/1uDfwssNrLlzY+F/ivhPcR6FQgUbl+NvXYY3nwMgb5RH8qHgxsWao7TsxVrvRawB ZGOCbvvrjoJ4HCEOaEGAjv+Olse9Trs9y9TKXglwFh04dgQ9Om0DjuPklOGVqbFpF1iA zs0UpL15qV+jw1slwgjcKwDPuLpnCTigJbs5ghiFYOeyczW31I4O8vTNlF35pRTF736v u97g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XAzIyho8; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a170906268600b0099238b86ef1si2301021ejc.164.2023.07.21.06.46.51; Fri, 21 Jul 2023 06:47:16 -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=XAzIyho8; 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 S230393AbjGUNTT (ORCPT + 99 others); Fri, 21 Jul 2023 09:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbjGUNTR (ORCPT ); Fri, 21 Jul 2023 09:19:17 -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 EA8A630D0 for ; Fri, 21 Jul 2023 06:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689945504; 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=LHVCmyopA5Gpa/p3+Tf6DYpT7yyPaihL3mV5AOHJdCk=; b=XAzIyho8/DboWSj3xN/J/72F8nZmEkC0lmX2CB/0WnpqFvwS3Zf0LcJOrqD5HmMr7MJ2Cr Laubjc3eX7yBEt2j7QX5o9n2Y6uJZuD6xj90IzeEWrz+U7N0rOK5lPRMDh/Wz1rYjFEpAC bj8vUGDdyrDg3aB9r7XbMfrOl18IyvY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-46-gPqUh22iP5KQ72sCd8VWSA-1; Fri, 21 Jul 2023 09:18:18 -0400 X-MC-Unique: gPqUh22iP5KQ72sCd8VWSA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C41080123E; Fri, 21 Jul 2023 13:18:17 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-18.pek2.redhat.com [10.72.12.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 771C540C2071; Fri, 21 Jul 2023 13:18:13 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mawupeng1@huawei.com, Baoquan He Subject: [PATCH 2/3] mm/percpu.c: optimize the code in pcpu_setup_first_chunk() a little bit Date: Fri, 21 Jul 2023 21:17:59 +0800 Message-Id: <20230721131800.20003-3-bhe@redhat.com> In-Reply-To: <20230721131800.20003-1-bhe@redhat.com> References: <20230721131800.20003-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772038113434471106 X-GMAIL-MSGID: 1772038113434471106 This removes the need of local varibale 'chunk', and optimize the code calling pcpu_alloc_first_chunk() to initialize reserved chunk and dynamic chunk to make it simpler. Signed-off-by: Baoquan He Signed-off-by: Baoquan He --- mm/percpu.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 1480bf283d11..c25b058a46ad 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2581,7 +2581,6 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, { size_t size_sum = ai->static_size + ai->reserved_size + ai->dyn_size; size_t static_size, dyn_size; - struct pcpu_chunk *chunk; unsigned long *group_offsets; size_t *group_sizes; unsigned long *unit_off; @@ -2697,7 +2696,7 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, pcpu_unit_pages = ai->unit_size >> PAGE_SHIFT; pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT; pcpu_atom_size = ai->atom_size; - pcpu_chunk_struct_size = struct_size(chunk, populated, + pcpu_chunk_struct_size = struct_size((struct pcpu_chunk *)0, populated, BITS_TO_LONGS(pcpu_unit_pages)); pcpu_stats_save_ai(ai); @@ -2735,28 +2734,23 @@ void __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai, /* * Initialize first chunk. - * If the reserved_size is non-zero, this initializes the reserved - * chunk. If the reserved_size is zero, the reserved chunk is NULL - * and the dynamic region is initialized here. The first chunk, - * pcpu_first_chunk, will always point to the chunk that serves - * the dynamic region. + * If the reserved_size is non-zero, initializes the reserved chunk + * firstly. If the reserved_size is zero, the reserved chunk is NULL + * and the dynamic region is initialized directly. The first chunk, + * pcpu_first_chunk, will always point to the chunk that serves the + * dynamic region. */ tmp_addr = (unsigned long)base_addr + static_size; - map_size = ai->reserved_size ?: dyn_size; - chunk = pcpu_alloc_first_chunk(tmp_addr, map_size); - - /* init dynamic chunk if necessary */ if (ai->reserved_size) { - pcpu_reserved_chunk = chunk; - - tmp_addr = (unsigned long)base_addr + static_size + - ai->reserved_size; - map_size = dyn_size; - chunk = pcpu_alloc_first_chunk(tmp_addr, map_size); + map_size = ai->reserved_size; + pcpu_reserved_chunk = pcpu_alloc_first_chunk(tmp_addr, map_size); } - /* link the first chunk in */ - pcpu_first_chunk = chunk; + /* init dynamic chunk if necessary */ + tmp_addr += (unsigned long)ai->reserved_size; + map_size = dyn_size; + pcpu_first_chunk = pcpu_alloc_first_chunk(tmp_addr, map_size); + pcpu_nr_empty_pop_pages = pcpu_first_chunk->nr_empty_pop_pages; pcpu_chunk_relocate(pcpu_first_chunk, -1); From patchwork Fri Jul 21 13:18:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 123848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp207852vqg; Fri, 21 Jul 2023 06:32:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGu0y2oBtSLFBm2fOP9ctYgPuAPu8F1pQePqR+Yks5qu8HQ/gd0spJvg08lyMIcfygyA17L X-Received: by 2002:ac2:5931:0:b0:4fb:7d73:d097 with SMTP id v17-20020ac25931000000b004fb7d73d097mr1225686lfi.39.1689946340196; Fri, 21 Jul 2023 06:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689946340; cv=none; d=google.com; s=arc-20160816; b=srN1nByqMSKbqag0D5CIv6f6chNw+vok+xpgwR3ncIVkaPDwvQXcF8psZmEOLrHb/c 00l4V+uBvgtpabW1OqC3YUdzUyaSmPDttGjb0sdVduOOB/pT/FXPowhv2xgTxOk1U0CJ SZ3pGaKa9rxe3Bu4Tux1FA8g6h2RhGB0b0wzQbEur1VYjFuwGjTPWbnuyQmR2/h820iV GU6B/axi8LgU7I3MF2eB7aUmk1raLtQiDVnJnF7SzNCUHwr8GyvddccLFFM/17XsUBNF HdtgGMSOvrdlk1UkGYq+apkArHW0mAgVo6sjbAGwQh5iNBt+SizSNWpOcSaw8ixqsWLD PQMg== 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:date:subject:cc:to:from :dkim-signature; bh=3RZSzIkl7Lg2t6SJUFm5Lmk6ZzRLZxYILlnvYuCsuFM=; fh=Co6b409Lrw+DmjUOZ9t4Bt8msCZwijfEojhQPoEHRbo=; b=B1an3PGWt9QJOVkA7KZbubj+j61cn3SELiGH8V/CrLGOKBU93tsgJTdQyf267XtZhU 55tLrWw0/XOpPJIihk3m13Ai3iE/09r2eJAiDyb7tFV192jhYRljlp1CJDhvynMJlNyu B8tEM4IaS2A8kF21S4URK6BQJEFgxAtNIEmaiMBDwiznbX7EcRRI8F54vOVbPco/ON1N /n2YGVQ6YAyl4RlHiMOSBQZT/WIPaeynNY6cPoxqQ9XvzWpAAkIZbK1uQLvzl/6Lbapa MttCyhoqGU+gzcPQ/NH9ev2aCeQjx0xqXc3Hl5B1Z/x2J/VzJD+kOFTC2r32oZz3Pat9 iggw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="aZ/TL7Vt"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oq11-20020a170906cc8b00b009823816586esi2085182ejb.500.2023.07.21.06.31.55; Fri, 21 Jul 2023 06:32:20 -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="aZ/TL7Vt"; 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 S230463AbjGUNTW (ORCPT + 99 others); Fri, 21 Jul 2023 09:19:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230436AbjGUNTU (ORCPT ); Fri, 21 Jul 2023 09:19:20 -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 764662130 for ; Fri, 21 Jul 2023 06:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689945504; 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=3RZSzIkl7Lg2t6SJUFm5Lmk6ZzRLZxYILlnvYuCsuFM=; b=aZ/TL7VthrpYJswHCVw9Fbv+oEl2nq9+mHRl5s4tVzozTUs+sVb4zv5UOoqQ+y7+RfQaoX D2R09/ABXFqE313maF+3DAAZ4ibLkvGieWzW0Wee1KcoBgqCufK33cKGtjTuTczKtSmto9 iShav6UWmp8VVPChHpFcDPGmrV7r7rs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-372-A6k7ExN7MsehoQtAg3USbQ-1; Fri, 21 Jul 2023 09:18:22 -0400 X-MC-Unique: A6k7ExN7MsehoQtAg3USbQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6879A8F184A; Fri, 21 Jul 2023 13:18:22 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-18.pek2.redhat.com [10.72.12.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DF6540C2073; Fri, 21 Jul 2023 13:18:17 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, dennis@kernel.org, tj@kernel.org, cl@linux.com, mawupeng1@huawei.com, Baoquan He Subject: [PATCH 3/3] mm/percpu.c: print error message too if atomic alloc failed Date: Fri, 21 Jul 2023 21:18:00 +0800 Message-Id: <20230721131800.20003-4-bhe@redhat.com> In-Reply-To: <20230721131800.20003-1-bhe@redhat.com> References: <20230721131800.20003-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772037173356186019 X-GMAIL-MSGID: 1772037173356186019 The variable 'err' is assgigned to an error message if atomic alloc failed, while it has no chance to be printed if is_atomic is true. Here change to print error message too if atomic alloc failed, while avoid to call dump_stack() if that case. Signed-off-by: Baoquan He --- mm/percpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index c25b058a46ad..74f75ef0ad58 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1890,13 +1890,15 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, fail: trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align); - if (!is_atomic && do_warn && warn_limit) { + if (do_warn && warn_limit) { pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n", size, align, is_atomic, err); - dump_stack(); + if (is_atomic) + dump_stack(); if (!--warn_limit) pr_info("limit reached, disable warning\n"); } + if (is_atomic) { /* see the flag handling in pcpu_balance_workfn() */ pcpu_atomic_alloc_failed = true;