Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6515041rwr; Tue, 2 May 2023 01:17:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4h9HnxBiCprHo9RHVrCRjgiSlDsaCZTowm0J7U9ulB5Qgo3lwKdpp0S2whGnkE5IH2mQZH X-Received: by 2002:a05:6a20:430e:b0:ef:ed72:779c with SMTP id h14-20020a056a20430e00b000efed72779cmr21433975pzk.8.1683015454901; Tue, 02 May 2023 01:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683015454; cv=none; d=google.com; s=arc-20160816; b=D7Z6OkbgasqP565kME0BQHXiqnZeQ/rX3BsZ+RS0iyRzwBz+cFaNE9M8ndg5cyI6q1 kp/oeOyfEmtE9B+1gfaa0vzotf7Sm25bEU5+9to3CnLd1YiqcZ1N69FXtvuqkbaFtBGq urJLQ93CuGumKci/KnNK6DbAQQTn++BuZLrqYnqiAvhpqbirCp+i1U4NJaWbIEevnzmi 3rRS2aKbeThgLY0rmYtNk+LV4KUqcTe+jITB8+V3bmby8wPxqlUXCVYbxntX9S5xytnD JZrkFCyZUbu5BXwZN78U5yrBxsX31ilHDxmj185fhHNxzLiOxNuVShC313901YopfCgP DR0A== 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.b=Poww+cKN; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q20-20020aa79614000000b0063cdf2e10fasi30201271pfg.212.2023.05.02.01.17.19; Tue, 02 May 2023 01:17:34 -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.b=Poww+cKN; 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 S233151AbjEBIM3 (ORCPT + 99 others); Tue, 2 May 2023 04:12:29 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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);