Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1393267rdb; Mon, 19 Feb 2024 14:15:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW2lSWoDDCqvP5P3kEURPEPxibLZhokIVw/ualuyUTKY4GOz20DBQP4jGtmC4ix4kYIyo9vkqtopr8xxvV/bf8W87IlR0NuyQG5Xqy0aQ== X-Google-Smtp-Source: AGHT+IFDlxItqs6B0mZZLsnjQpniwBwHcRwpqC0oUDREeecB4jR4F6+YFwvE1W6SnoqnYbsrplyA X-Received: by 2002:a05:6a20:9f98:b0:19e:ca3a:612b with SMTP id mm24-20020a056a209f9800b0019eca3a612bmr16059159pzb.54.1708380925037; Mon, 19 Feb 2024 14:15:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708380925; cv=pass; d=google.com; s=arc-20160816; b=Wx5hFqzldskmViEGdUd3fpHqCM0ogzHvc/DbqRaOMuLbRS2ceYMJmsY83Iyty7xvIT ZKbNii3ZyqeEIRMw5LCYj3k51GzgJH7Ajx9gVv4DZhfyTkdQLKDIrLSZDFCNNw3sxIgq ooOhriquj5KcyfCkjSma5rza9fRMmkAYB0MUhNb+s/YiGb69p9GvPkiFeWgS/Y0vV36y a3gqCyDSNnmRyVrS1jZ0CU9KbbHJAC+WPQlKa8EqDdNo4CPVtPIw8g+UiqIc0/EIc859 H0VOUaGL7MFpzdqyTcQ4ruhRLJmHD4NR1CQJat9ejSXe9d8GoKivKnVFhtROxvz+sV7E 9u/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=12EwYtoovs7N+bPhOenXccMlj0F0605/jt1k8W4RoP4=; fh=xEnupBEAmL5+NNmSpPembZuaL4ewpc9dNeR4PyVso/E=; b=xjn68d4ir/anWtiGhmKwPDQSBuV+FOu+ZFYVKhl4DmS6i07Ul5jpL1wRTn36+phIEp V+snD7kES3GMNBDJJsQmm2ERu+zcB3MFGeyp/XOoSpaTIu25Tc9RWyRNS0edchvwQXGK TLcQuuFow+bAuvx7e45fB42QcVzZMzzAbrqjO+LqndLIsR4ppIgCv/jTBVZx4kr6XOWR fFJF6OhYysW6A7PMx/fhUSAXfXEveY1d5d3/4ZZwRtZRrw2Siy9YGLnEKeH0+QL86/No yRopcf12cJaTi4CcDH5paC0AxNH20J75rzM8fNL+vi47fcVGQ3WkfVCO2NGRuk+wrug2 CJSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nD+lwICU; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=IShX35FE; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-72048-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72048-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y198-20020a62cecf000000b006e370418d33si4028546pfg.169.2024.02.19.14.15.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 14:15:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72048-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=nD+lwICU; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=IShX35FE; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-72048-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72048-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8283B284ED6 for ; Mon, 19 Feb 2024 22:15:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B16054F90; Mon, 19 Feb 2024 22:15:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="nD+lwICU"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="IShX35FE" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71181535C6 for ; Mon, 19 Feb 2024 22:15:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708380918; cv=none; b=Nc8zcTyA73/+yQ7ycx2EoRolRLtrSgKQeI3Bo8m3Q0hpBIjww7fVpg+MM2myxtC0zXkcjc2VT93g3htJUgA1cMbLMt54bNgdCyXLcShsFMRIcjjLBAMa/BXEGm4wA3Ixqek7bR/3Czm4ofPcnBoa/iro2Iv2tpRwfkS02k/kQdY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708380918; c=relaxed/simple; bh=PQglBkR3rLv47oc/aLGA+N7REgcT5RVpd2W7+0BOZEw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=dGhpE1UB5F+a344NMfRcBINcfgr8bep6Zk47Zx5JoY5ewgB2mgT6S8IHF6MXL3YsjBeqdG4sz7CETwZDc8UJDygjOKWLrlupufX1TgHBhlVJXT3Tgc9X3hdMLkB/WKBDzgBfHdm28NhyQULZE2GftvBLe/C4T2PgpmxOVvHLXag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=nD+lwICU; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=IShX35FE; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708380914; 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: in-reply-to:in-reply-to:references:references; bh=12EwYtoovs7N+bPhOenXccMlj0F0605/jt1k8W4RoP4=; b=nD+lwICUPrIdUVZIBsvdd179b7ERiQFMYGY7KASvsbo8bU0LDIna7FP3FvQxige9rFMxMf yjuivj42XoIwKhLRn26nS/2NI0B3DPBHGAhTwRjgjGwtltmDmab6vsj+a52B069rbggPQb uK9ahrEY0VGkzRJumTZkSbUZ2xw3GEZR6f/vVyOcGUUfFngnBxPA8UKGJ2PKHYQQhQVsDh 90Vc0ccLuHUlCgs+m0poOsehwDKIx75UXQWUdx1FvEe9pE7yIaZxWsmaHbGKXPf9Vno1cc QCG5CdNbfs36iZRt0S6D++B90G7S7L0XurB+rS6na1dRfoXdl2faw7lUKNWayQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708380914; 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: in-reply-to:in-reply-to:references:references; bh=12EwYtoovs7N+bPhOenXccMlj0F0605/jt1k8W4RoP4=; b=IShX35FE+WPZy8e7MqjilIjJncIzQ1u3g6z83VWr2VLTWTyqZXah/FlmZfd5jTc8MNr0Zq hAzxdo2ySdb+vtCQ== To: Bitao Hu Cc: linux-kernel@vger.kernel.org, Doug Anderson , akpm@linux-foundation.org, Petr Mladek , kernelfans@gmail.com, Liu Song , yaoma@linux.alibaba.com Subject: Re: [PATCHv7 2/2] watchdog/softlockup: report the most frequent interrupts In-Reply-To: References: <87mss2dkxo.ffs@tglx> Date: Mon, 19 Feb 2024 23:15:13 +0100 Message-ID: <87wmr0hzim.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Mon, Feb 19 2024 at 17:12, Bitao Hu wrote: > On 2024/2/15 19:30, Thomas Gleixner wrote: >> On Wed, Feb 14 2024 at 10:14, Bitao Hu wrote: >>> + for (i = 0; i < NUM_HARDIRQ_REPORT; i++) { >>> + if (irq_counts_sorted[i].irq == -1) >>> + break; >>> + >>> + desc = irq_to_desc(irq_counts_sorted[i].irq); >>> + if (desc && desc->action) >>> + printk(KERN_CRIT "\t#%u: %-10u\tirq#%d(%s)\n", >>> + i + 1, irq_counts_sorted[i].counts, >>> + irq_counts_sorted[i].irq, desc->action->name); >> >> You cannot dereference desc->action here: >> >> 1) It can be NULL'ed between check and dereference. >> >> 2) Both 'action' and 'action->name' can be freed in parallel >> >> And no, you cannot take desc->lock here to prevent this. Stop fiddling >> in the internals of interrupt descriptors. > > Thanks for your analysis. However, I have a question. 'action->name' > cannot be accessed here, and it seems that merely outputting the > irq number provides insufficient information? That's what you can access without risk. It's better than nothing, no? >> and the analysis boils down to: >> >> u64 cnt, sorted[3] = {}; >> unsigned int irq, i; >> >> for_each_active_irq(irq) { >> cnt = kstat_get_irq_since_snapshot(irq); >> >> if (cnt) { >> for (cnt = (cnt << 32) + irq, i = 0; i < 3; i++) { >> if (cnt > sorted[i]) >> swap(cnt, sorted[i]); > Hmm, I think the approach here isn't optimal. If some interrupts > have the same count, then it effectively results in sorting by the > irq number. Is my understanding correct? Sure, but what's the problem? If two interrupts have the same count then the ordering is pretty much irrelevant, no? Thanks, tglx