From patchwork Tue May 2 08:12:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 89279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp444961vqo; Tue, 2 May 2023 01:33:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6bJs2trBcfFrmQvRSdCCueBRXjXhc0vo7Ou+0btDX2NKLhpaH/UlWy+0Rh+Ou2OSMfci0g X-Received: by 2002:a05:6a21:32a2:b0:f6:9492:93c0 with SMTP id yt34-20020a056a2132a200b000f6949293c0mr23121370pzb.29.1683016425570; Tue, 02 May 2023 01:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683016425; cv=none; d=google.com; s=arc-20160816; b=sEwEutKxZkz96oiEjAvO8Lcl7XwUrZhTM/ApQLhwRBKwz7byLhSPaxyaeSIMNbnv5J U8UznqarS2upKd4lbugI1nLS+HnDkLksobMf/iv5Nu9e9nXkhky1ppShm1BRvdR9dPfy EbKMd8WUdfpB+FOdBs3lCj+mUOb7Cr5E602TD5riEY7lnnKnFyZIJJ+zK2+NMeZBrPwI 1CmLy1e7YH3+zWwZJR5pTSJ4iAvWrZP+awFcHV7mTpKNaKosHNCk/qAEDCxgfXT0dTyD iXfk3pkEJzC6jqyN3ulYqng3qeBjCzNqDV/G2UAliqfnbaZREw9WmeETg/VNb2NIBWsP KmvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=M4wkqt8zGvhlDhOnkrLIF/F3emolKIX/SCnr5m0IpSU=; b=j6J8lfgRklvTJCWQeY6pRJp4VCB1GyvU/9S8YooXiSx6LNj+qaj2n5VSh2ZctmdyR6 tNjhmGvU6GRaLwrK38vPOyT4/0kHbkQPZMo0S23HTW3BtUVv7j23INrmfcO6RIrNClPM ZcETK1xImLPRZeYJa05p522ofHl5LJSO+uyiyvkp5TfQs66IFjV+ZVkGUIBUldo77Xdq kjBfD+SlybVtHDTo4uwGb9DpUp6aoFKXyGidVpjJkdy48SsmTc71Za443y2+64mhzWYg 0hXMG1rixLMEw1XVLuN3CqW2nTQaBN90boQPGeqnfPsL6uKOyjXVOOkikI/+EEmOhe3l PDxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qtKyLR1H; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 73-20020a63004c000000b00528b2a08a3esi11224221pga.425.2023.05.02.01.33.30; Tue, 02 May 2023 01:33:45 -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=@linutronix.de header.s=2020 header.b=qtKyLR1H; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229722AbjEBIMa (ORCPT + 99 others); Tue, 2 May 2023 04:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233602AbjEBIMZ (ORCPT ); Tue, 2 May 2023 04:12:25 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178C046AF; Tue, 2 May 2023 01:12:17 -0700 (PDT) Date: Tue, 02 May 2023 08:12:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1683015135; h=from:from:sender:sender:reply-to: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=M4wkqt8zGvhlDhOnkrLIF/F3emolKIX/SCnr5m0IpSU=; b=qtKyLR1HnRzssc2Itk3+asvrAhS3V2PvQAqybrU2KIzYuT0ONN7+4qmWJzIxG1BEHL4LUM /i6rKHKX2qcR4jpiHmqr9f4VJeCS+nMwrzcxFcsQFFte6pFwjsdyN6c0QGGLMjO9dMVudQ xw2OpWZPQCynapdzilPReLmv0BO1tAWW5lqg+52XeZv8lH9fGT1EMKNbSIvu4Pqwh3dzxY hdAyHOAXNTzmyfm3mK2F+tpQqAAdn4RSJ490sDLhh8w0DWE6NTGV9LDgJaTdVJAtpUDtIZ E4SfNgmcCJilaLAQk0ddWMQMhx+fMEdnhl0awLCKgZOL5j9m05rWth/tdo4KbA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1683015135; h=from:from:sender:sender:reply-to: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=M4wkqt8zGvhlDhOnkrLIF/F3emolKIX/SCnr5m0IpSU=; b=Poww+cKNbZ2gvG9/jBER65CNge9aJFTl9rLn6B7pBHqdwiJl9iQYtbws6YgeaqOp0CHgaL E1HdNhqJXG8/5RBQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/debugobjects] debugobject: Ensure pool refill (again) Cc: Ido Schimmel , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <871qk05a9d.ffs@tglx> References: <871qk05a9d.ffs@tglx> MIME-Version: 1.0 Message-ID: <168301513479.404.6581313024633204676.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764770631681885350?= X-GMAIL-MSGID: =?utf-8?q?1764770631681885350?= The following commit has been merged into the core/debugobjects branch of tip: Commit-ID: 0af462f19e635ad522f28981238334620881badc Gitweb: https://git.kernel.org/tip/0af462f19e635ad522f28981238334620881badc Author: Thomas Gleixner AuthorDate: Mon, 01 May 2023 17:42:06 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 02 May 2023 10:07:04 +02:00 debugobject: Ensure pool refill (again) The recent fix to ensure atomicity of lookup and allocation inadvertently broke the pool refill mechanism. Prior to that change debug_objects_activate() and debug_objecs_assert_init() invoked debug_objecs_init() to set up the tracking object for statically initialized objects. That's not longer the case and debug_objecs_init() is now the only place which does pool refills. Depending on the number of statically initialized objects this can be enough to actually deplete the pool, which was observed by Ido via a debugobjects OOM warning. Restore the old behaviour by adding explicit refill opportunities to debug_objects_activate() and debug_objecs_assert_init(). Fixes: 63a759694eed ("debugobject: Prevent init race with static objects") Reported-by: Ido Schimmel Signed-off-by: Thomas Gleixner Tested-by: Ido Schimmel Link: https://lore.kernel.org/r/871qk05a9d.ffs@tglx --- lib/debugobjects.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index b796799..003edc5 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -587,6 +587,16 @@ static struct debug_obj *lookup_object_or_alloc(void *addr, struct debug_bucket return NULL; } +static void debug_objects_fill_pool(void) +{ + /* + * On RT enabled kernels the pool refill must happen in preemptible + * context: + */ + if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible()) + fill_pool(); +} + static void __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack) { @@ -595,12 +605,7 @@ __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack struct debug_obj *obj; unsigned long flags; - /* - * On RT enabled kernels the pool refill must happen in preemptible - * context: - */ - if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible()) - fill_pool(); + debug_objects_fill_pool(); db = get_bucket((unsigned long) addr); @@ -685,6 +690,8 @@ int debug_object_activate(void *addr, const struct debug_obj_descr *descr) if (!debug_objects_enabled) return 0; + debug_objects_fill_pool(); + db = get_bucket((unsigned long) addr); raw_spin_lock_irqsave(&db->lock, flags); @@ -894,6 +901,8 @@ void debug_object_assert_init(void *addr, const struct debug_obj_descr *descr) if (!debug_objects_enabled) return; + debug_objects_fill_pool(); + db = get_bucket((unsigned long) addr); raw_spin_lock_irqsave(&db->lock, flags);