Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp529061rwb; Sat, 13 Aug 2022 03:22:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7LHwHC60nXs/YCd8S+4T+OIAl5BUhHewPqOTveVT9yhyroEJLNsOf4ivIr48Ijs2HeUCbe X-Received: by 2002:a17:907:94c3:b0:730:9641:8dd8 with SMTP id dn3-20020a17090794c300b0073096418dd8mr5225414ejc.586.1660386174792; Sat, 13 Aug 2022 03:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660386174; cv=none; d=google.com; s=arc-20160816; b=hX5DyEkywZOVDGQjuRZuLnnIL7ypbzYugdtwlUAjNA5Wim3ThqLgo5TaXA55jCZ6y7 tK+6I8CI4SkOhAKXeGflMc/S9eW7cEHp9I08/rHQGfzM6WxJy6j+uoD8u6fRQ0TCnYan sO6NTAx9efShqiIeXWl8a1xWuh1Ehbs6mLIQ9frFPh7/VNtvFz4mkbgN9+VFP+RuYSkd kpSnc5qXihpKJNYRq3gffHLui9HYD0RkvXhSFJy3o5c8tnVkThzhTE0T60M2lv81OXDH dnOUNPwa/A8sMUrqfT6raqyJDwsS2ulS2kjdRlijYF2Nwb4/nihth46HOUC+9XVm0xNk 25dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cN3EiT+fEaKP7OaJj1ZSByutugxIw61q8WkMnaotHS8=; b=orpE/WvGoPnD4RUZFk6S8loBYKo6ogrX/6wCfSfAK6m6RR5DEp2gUjGJ0CQ5Chmfxr 3gs79g+vXwmXnOmG0EhsyfsAgYpPtzmtXc7BXmwfnpW3l5zCa8xMPI6GqmfDJlYAjRAE p0Q6lNqyiJTKHlQb7k3NFtJ/LxmPUVkirsVTa9trLcDdzFCYTGamxTFl28vjzrdca/iG pnvescpMe1snkbPmrUspc1MLA9MEz6DGAY+TfKTZeU/IbtuXcRQreF4hgSG7RG4oUv6h 1gJk38qJFO62AN8XGm7aI/WKr0d4YoU0Rpo3yyJLyW5lxxNVS0NfHB5f76cpAju9vWoz lrVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=C1Z9dyGX; 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=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs8-20020a1709072d0800b007310123e39fsi4293384ejc.721.2022.08.13.03.22.27; Sat, 13 Aug 2022 03:22:54 -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=@alien8.de header.s=dkim header.b=C1Z9dyGX; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239081AbiHMKKE (ORCPT + 99 others); Sat, 13 Aug 2022 06:10:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238496AbiHMKKD (ORCPT ); Sat, 13 Aug 2022 06:10:03 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E18FDFE0; Sat, 13 Aug 2022 03:10:02 -0700 (PDT) Received: from zn.tnic (p2e55d27b.dip0.t-ipconnect.de [46.85.210.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 0BB1E1EC042D; Sat, 13 Aug 2022 12:09:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1660385396; 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=cN3EiT+fEaKP7OaJj1ZSByutugxIw61q8WkMnaotHS8=; b=C1Z9dyGXgnylJzqRJBge3xZySP8pJ6ZA+K3iuW97Eg7OkScz40l1+68Usso37VmyY0A2dZ XuGU0JeXMC5xE1ilcAHvXT/yRgxR3cqXk+mcrw4xdLk8DDsyibHBT4S/mJrd/kpmNSoras bSbu3MaSHrGtkDHoLqOp+hG2zjcRYnA= Date: Sat, 13 Aug 2022 12:09:52 +0200 From: Borislav Petkov To: Mateusz =?utf-8?Q?Jo=C5=84czyk?= Cc: Yazen Ghannam , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, tony.luck@intel.com, x86@kernel.org, Smita.KoralahalliChannabasappa@amd.com, mpatocka@redhat.com, gregkh@linuxfoundation.org Subject: Re: [PATCH] x86/MCE/AMD: Decrement threshold_bank refcount when removing threshold blocks Message-ID: References: <20220614174346.3648305-1-yazen.ghannam@amd.com> <7c8e34c8-f12d-e7e4-b6bc-4867824865ea@o2.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7c8e34c8-f12d-e7e4-b6bc-4867824865ea@o2.pl> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 On Fri, Aug 12, 2022 at 11:14:44PM +0200, Mateusz Jończyk wrote: > Shouldn't there be "kobject_put(&pos->kobj)" here instead? Yes, it should. > Also, it seems to me that "kobject_put(b->kobj);" before the loop > may be relocated after the loop - so that the refcounts on the child > objects are decreased first, then the refcount on the parent object. Yes, I guess we can do that. > Additionally, shouldn't there be a call to > "kobject_put(&b->blocks->kobj);" in __threshold_remove_blocks()? Makes sense, we do kobject_add(&b->blocks->kobj, ... in __threshold_add_blocks(). > From what I understand, b->blocks is a list head, so we need to > decrease the refcount on it too. Not list_heads - we modify the refcount of kobjects. See what the arg of kobject_put() is. > After these changes, the __threshold_remove_blocks() function looks > very similar to deallocate_threshold_blocks() function just above it. Yes, minus the list_del(&pos->miscj); But that can be made conditional with a bool arg to deallocate_threshold_blocks() and then remove __threshold_remove_blocks(). Care to take Yazen's patch, fix it up, test it thoroughly (you should enable KASAN to catch any potential memory leaks) and send it? Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette