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: 13321975 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 074BFC001DC for ; Fri, 21 Jul 2023 13:18:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4038C6B0071; Fri, 21 Jul 2023 09:18:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 38CC88D0002; Fri, 21 Jul 2023 09:18:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 191CD6B0074; Fri, 21 Jul 2023 09:18:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F3EC46B0071 for ; Fri, 21 Jul 2023 09:18:17 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C073C402CA for ; Fri, 21 Jul 2023 13:18:17 +0000 (UTC) X-FDA: 81035672634.11.E0E9574 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id A49FC12000E for ; Fri, 21 Jul 2023 13:18:15 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K2S4aYKl; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689945495; h=from:from:sender: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:dkim-signature; bh=+qYMYKznWRCQRLs4itQFPGrBm6WN+EZaQC54fSpIxmA=; b=iGg2lzn9RSid36CWyMvviJhb1bJ8utZtrB7uDuMhFbPPYAP9Aj7ag8zB7q9YKQrSmqGsnB s6w1zp7ix0EItaFZs4t4KLTKfX8KrVxoeKbgoZmcdr01IrqEI7mxnp1Hx9jdB7aaMo6vgC xSU4E5PMixaVm7zjiArEPVUKNEKy4cw= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=K2S4aYKl; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689945495; a=rsa-sha256; cv=none; b=I3qcfGlid5IQegBE+WKrjbZGI7CJ7bM9qcKoLndaQDUBx3xiN2V0dghKijN+9fH0BUZyfr RF5gxEXQhq2wAAC17DC9PC8On6Uyoz3XY0zlQmQQTCxmuSRtoQJSgt1iGb6eaHTcYv9tBv Ga0g1fjkxpry6ntMtdNjIjrlt0J4wro= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689945494; 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=K2S4aYKlhqsF1Acjyf54Fh1L6IYNb1O36PNNx9syS2aur3J8iyDv98e/JFejU97vN7ienO 447W/9fo5zaIDCxAFhpojFyTzVdde8Cb9SjitaWJXKLe54Ir1QtJ1DHOMflmHq/e1sLjqt WxfBVv48vUrTqqkagAH3/NIWeXTabRU= 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A49FC12000E X-Stat-Signature: y354hqsf1wfgfb9krjump9hpyxwz9ha4 X-HE-Tag: 1689945495-253542 X-HE-Meta: U2FsdGVkX19uZrdEWqZ4fAPxRUKVeTUQ3DJAjnE1Mel1z60wGlMAymtNU7EdqT2gyzEfxqKBsScMxXHjxDZ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/AHqofOkdQfxbEfSaNQZuTtJIX6rsE= 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: 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: 13321976 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BAB6EB64DD for ; Fri, 21 Jul 2023 13:18:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A93B58D0003; Fri, 21 Jul 2023 09:18:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1B718D0002; Fri, 21 Jul 2023 09:18:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 895588D0003; Fri, 21 Jul 2023 09:18:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 76CC08D0002 for ; Fri, 21 Jul 2023 09:18:24 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 469B7B13EC for ; Fri, 21 Jul 2023 13:18:24 +0000 (UTC) X-FDA: 81035672928.01.27BC00E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 52FA72001D for ; Fri, 21 Jul 2023 13:18:22 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TRZPfvZM; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689945502; h=from:from:sender: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:dkim-signature; bh=LHVCmyopA5Gpa/p3+Tf6DYpT7yyPaihL3mV5AOHJdCk=; b=CkbNTdBagNrc7D75TsNn5HG5k1bJulUtV3visD1ea35ZJ7j9+HxJ/UicCcMU1EoMhsOmbI 1RXhnvdkbQTTIePud9S0tyB6RREayYYmlevQZ29me0VmSvbNB6xFrXXHPSZfE5meLSJR4S 2hCtcVTXqWp6V2dVbx5UnejcSARQ1qo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TRZPfvZM; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689945502; a=rsa-sha256; cv=none; b=5NXGqYWeqEecg9EwQgyTVcEPQ8sXEwUFe/ol9w2NH8Ij+LlVGrNq5p7HjU5BHu2niwEbjN m9w2zglmAqCK+CJzb7ZBrOdIgVTwTU5AbAuohrwrZzJHVrXAy7WuDlraph5iImWGCTPzfJ emm5xlwES9CU7w3FJHrzsMlbf+ZmH0A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689945501; 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=TRZPfvZMl60v1FUXjAXQsiyd9NcPn7L/NZJutjHBFZ2bCU7/WLMlSNlDTpj1ne26Ilb9YT 5AyT1g57AQ0jCDi+/5RRpLg0E0Tws3bE7bniOGOr33TM2XI2pTJXAYT7pyZ+EuUl+YDs+5 DvEK67uCNSiixb5VDSMUx5RV1ZUpD4E= 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 52FA72001D X-Stat-Signature: 1k6a9kwxbqoujaamncdf8nj718wijbct X-HE-Tag: 1689945502-806869 X-HE-Meta: U2FsdGVkX19Zvo6pP5577aHWL4OuMSpbr0aIY1IEF3Ht5lsk1ktAAEL5/V0Rk8zSf76nsd6/3ke7DMd8beeZ+8xdGZXGd5hu0x+24saG481PfFkviXj6YefYM7d6O7IxatsCNDIyKYrx1d43xErtxDDUR1Wy3QtvCeIrsCyl0Ydf1xFNS5ixJ+j2dAgm9W6dDXE/AwdnITkC/P7gK7EN3JQEv8b7J0FXpNTzwb11iQTnN7x/WD/wuNE1YVaG68a2JY8Z25cwWjkme0WD8Ls53RFfIKyklVF0lL+u8eLUso0SgSzbp43xq1JnGaA+YFzH208f+72A65BqpeHNZ2ODU+ErumwNcvMYO/IQbj0j2/y5cfvJhqFUert0tzATliHI8hCvtaaapCgG3TnhTCWlqZ9CLBKrjTishPKBJW8SaL9Tj2cuuZA6dEF38H0xYx3wXQeykG5Tp427R2S9BpvQqbua/SX55EEPfbiuwF2DfhfWwI+1gWXew2sXw1pHYSt3hZXBr/Ko7eqHrXfbqiB8OoTk40j1yvu0lSK2wesDSK/2p3RokX5YKvYXdmkDrJVJhquXjfJgeGaDnOJHc1U8mqiVAX5w9fgMtXQQW4YqZIJNx/H1Axjtyo6Q7HTfpfus8HrWCH/7li9Eioc7LJcWZGTuDvULaltuDMTfgFx7TDq32KB84AB/XiUUOOKCwC2+vftQp3qR+pmDPSukcEsCtDZ9Pyg/KvH2eF9RGu01W9EYt66URkjWeYKWP6hc7/T//SieqWjx/26jIUawWwBGQpiE0jybxL/QAEMZWtfh92Ut9aDNrWKB8s8xclFQ1UYFlhTPgSJu9lMWvlEyfuNi9Ta2YxR3sVoRSo9T0YvJ3jKCxz4cu8QMb+RDbCIkeg7RzrzXjng/Pssxu5bcwwIVJFyMK19aXqjDSJABllRDa9Tovpzwzi6eNX47w/tTc6t0cRAH5H2oCiYn9AbNrSe JaN3ne3y M7jHwnZAj2ITVPqlP49+/G2QCZkZ1wFF1MvvAXPg2Sqwq1tUk2g9N8ikbSH+qbRtWE0B2kEkS3idS102enc1VhF31hiZ8zMbaLiSWpuz95hRsYjKl28hPfby1b7F1Ub/PS3TrmcbQweOJ5J46YnQ3n7rNdX2sEmin40wHGwe1gfRnM7oDqzSAa1dwfbi0AWoGCZkTaCBk/ZM5PzKAg1IGKOnbMQ== 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: 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: 13321977 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26883EB64DD for ; Fri, 21 Jul 2023 13:18:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2F6D8D0005; Fri, 21 Jul 2023 09:18:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB9618D0002; Fri, 21 Jul 2023 09:18:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 931958D0005; Fri, 21 Jul 2023 09:18:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 83B3E8D0002 for ; Fri, 21 Jul 2023 09:18:29 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DE074801DA for ; Fri, 21 Jul 2023 13:18:28 +0000 (UTC) X-FDA: 81035673096.02.7F268E7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 16B0B40019 for ; Fri, 21 Jul 2023 13:18:26 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dkeZj72q; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689945507; h=from:from:sender: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:dkim-signature; bh=3RZSzIkl7Lg2t6SJUFm5Lmk6ZzRLZxYILlnvYuCsuFM=; b=eptGJzJVKivYX6dqCJjN0KXF8reSxCQw4NcYtbjp4e4YghYCiZcod6h0O2sTBZk05rKzjO Hb4HSPFg2Yu0COXXd21IkI4BVlrRHGg1q+Ncg8Tay6FLT+bglnNszjEW5a+fNTAywu3Cov vvqqANVGdvr/za8H+Klb6c5NFc5z2Bw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dkeZj72q; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689945507; a=rsa-sha256; cv=none; b=LEkM7S9dVoiMyNLxdSXe0qx0XEGOmPukWVI4NEVgV5UVPUB8GnwNBhM0ezVCmrcNw2Rau6 Ef85mpJNc4r+wog5jHGmI6b+b4keak2Hv/6vSfqcOVrx6EjoTAScVwitXOHUuiGGen8Wjs 48vgq9cufHtxGoK+Em5E0RE+OUAS3B0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689945506; 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=dkeZj72q3cQp7e0bsLoOt4ZI6izKF4CO5A1oeB7ncnYhD/U7zrqj6UP6RPN5CNWd90RWrk nMZcxfiwFtBDZ97P82oaBRAZytZ3QYoQPJlJl9KbYvtO4REQI7GYNnRUHo90SEx9+eeIG7 ddEyeoQWz1g7XD3RMsmGPGK0zkTd4o4= 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-Rspam-User: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e80o6hX M0ccsqgE qFOxbS5nCDexQFOp0USBq3pKwGnxJCALCcqF/xPIMCoUSetNDmiPIHsfuR1mkPm+JhyjdRxKg/0nCm9GnQJ8IkOFB0z58aZMYgsYRKdcxs/DQTgLtbvs1u3hfRgx3iQ+r25UbKqYJuj7G6i68s9Q37iFcRjlwLnrooAAi45lyZad1KAU= 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: 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;