From patchwork Sat Feb 10 23:49:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1701030dyd; Sat, 10 Feb 2024 15:54:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGDvjcescEWujlddGV9BfaHnFv7JC8tPj+4uo+Op4Llwu8pvpUIKJ2nevf2YJsPjlhvySW X-Received: by 2002:ac2:4189:0:b0:511:3bd4:6a97 with SMTP id z9-20020ac24189000000b005113bd46a97mr1751279lfh.7.1707609255476; Sat, 10 Feb 2024 15:54:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609255; cv=pass; d=google.com; s=arc-20160816; b=rdSWVozzRqNgWhcwiilX4SG3VM0InYrGXZ4iyBbP2vamCdGq+eQ1Hresid86YLTyhp CUs5HPlJVmRwr1yaUFNmKBIXL3+4LBB5W+wS1rxL/pijlJiSILSLV9GIUYxtfr2ebp4i HGRw335o3jXYpUPz+AbqfeqnuEOrXDza2BJk/e24PExCu2JgoZAgJyNNrpiDeyi8dMoj C9pq1fT93ey0mysVCX1A59ieC0sjpFtj9bKtHexnelfqaeEgDfPk7MSTHtB8i6KPAaTL i/sFsCiB1SILJfnrJv7bAKzlmRu/PKVkLYhnJKaLIB/n5t8KhgfGt92KC9Bb7yGEKl6d kMSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=m0C7d9TR7oCLKiGX51PIEVgdXmMwdwdVpasUDDkUmDA=; fh=HgJFe1YARO9U4Hszhg0ENOJhooLguIS0MG7VQkhp15A=; b=cCIGdAqKlMmr9KbMZHkLBHgH2+UVM1aqcpZxd9e9bdngAOseqJBfjZ5WzmWACv58Or FoJXVHkdVu46pbsjcx0h4xlSXPoYqncmkPOLPDSeJWaoylq0GRvqq9t/PV4YU+Cvds/0 CY4k4LLfPEXx8ouOfiTpMm5GzYfu9pEXpfWQh84MQDtEQ49yQhrQBSUNWl0zqEE0PWYV g/O8c4pQfxsVWaVFtrRtMvy30l4ZLbeLx2YYv5JKaEUJVW5JDquwoN+Ms/r4hfBciA3w gt1fh0kkDvGaKHTd0YTPFKoX9Xaq4EqChG8UCcy1PLzretYLPFo/CEXsrs16zj9qVJvl hWeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P0YfpGtR; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCU3t0eYosTpFkAt0VJBzWmurKgY38ZkQO+H9Skw20DT3gJdxYLOpzVosNd+K4TaTXzhaELevVRobAquU6Yz+6rrvdcgfA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id rs10-20020a170907036a00b00a389a9f49f1si2386420ejb.660.2024.02.10.15.54.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:54:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P0YfpGtR; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id E331F1F21921 for ; Sat, 10 Feb 2024 23:54:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BC18612EB; Sat, 10 Feb 2024 23:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="P0YfpGtR" Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9831060DD8 for ; Sat, 10 Feb 2024 23:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609056; cv=none; b=LICE+LxI1DtWCo7H0vYfSFlhZAY/n1/UUXyQ+cKcQLqr/9LEOzgq+Ljex2j9NoM5K7bl+nNQY32r1BXl/qAIw/EDiN48EpjGrjaGHhBY85SrX6Gk6493uj+C+wKy/QaERXQvIKbTDcVbE8Z/VaDsLiXa6js/Vu2Xub3GztsrCIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609056; c=relaxed/simple; bh=svE0ydmRhksE61Jfxvr6jlgMjC0XYATtTVPi+1xPOKE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UMj1Exgd72kIgQ1WIDXDErtx9Eg9KfC4wX0EZKaZ2gCkoJc3AvFTp4ZklyARPxZcr4xs8G9QLQFxogQ2P+NUP11ft0yAfcL4p3EMUC4sSkXaw3TjMb5rJGEvn6mm5a6xu1Ou06uhXcu4/kKYLLw7JK5RLAz+yF76+LBslgkIOGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=P0YfpGtR; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5116b017503so2861643e87.1 for ; Sat, 10 Feb 2024 15:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609052; x=1708213852; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m0C7d9TR7oCLKiGX51PIEVgdXmMwdwdVpasUDDkUmDA=; b=P0YfpGtR2+eCi0IIqVbftRscTbJjJy9hrTF50DkXLhGDGBB8vXd2gzdGHxvwpq4ToS q3DcKqQhXCgHCKy77xnV10SoTTpvfB1PXBWeyimoyvLmmAezJNEJlW0loNLHzajq5hyl b3zwJ5zmuVuxYE5qPUr7eB/XBofXzUC5xHMr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609052; x=1708213852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m0C7d9TR7oCLKiGX51PIEVgdXmMwdwdVpasUDDkUmDA=; b=ZXhV42CfC/una1z/IIdLmX9NtpH19g664nNPbmvTS60dmfjTWmnD29zKmBgvf3gy2C Xz8IP8NjK2qidh5fwaEscRPvko4E3QUvfWPSpOqLlputyvYPpcwK1MMCOBqnZQcJyqcs Vm/tgjxfDEEXmB2exJgn5+Vx2C6u/HtISQuJjQ8fFeOFnJkQ1g+74ua2t8kj0fbC2HiH kI3nBV6seJ5wlz7fwlEmZF7N9Ew2YjmaMqT/KYEupIYYErEd0zkaTjXae5jrx9qUoxyU FexfifUN9ZaF8vtUVSWwUXlLQCHcfXC8EM+huYQSHsYiijpQ9wbebQU/jwK2+C1ohvB6 3FAw== X-Gm-Message-State: AOJu0YzvresigdUUC1aNpW+/bH923tfwQsSZQCuKcB1THY04OjA/7CbW wIJbcPpQXoPhBK3qPLWmzJD8OSYt6cLwLGZ5LfoUDGKeBUG2DhK2Hw38ldyS X-Received: by 2002:ac2:5dc8:0:b0:511:62ab:5f03 with SMTP id x8-20020ac25dc8000000b0051162ab5f03mr1878907lfq.60.1707609052801; Sat, 10 Feb 2024 15:50:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWfdpieG7Xq0wJgEwvOp+MkQV8u/MwIyUikMGTNVVNK+dwp70vbTGfyuvR/QCLrvUxKN+egISXAcQRkIktfSY9x02li3nO+Dwlg91zKlh2LiY4awAbjA35s4xGLTsTJEZbZ4VfNHcstvRhRKHv1BmtBIWQx52FEDhNHxH7RqkhP5KOiEqGxzzKaIlovMvMkP+2clrjrnab/+TshTe0O6uT9G1FYmSRycqbWUwFmvSQmxXZVwtx8pBRi+rQGxtyT5yu4ksJ8Aj+zacXk7OU6VOgz6UFc+HC6klD7wtgOrSrFr0rBqPfXXoaC4rQeaKibU4+bnyahEvFkgoOJM61CzUqetuejAP0EQvH+iX7l/UuDlHYoUx7B1J72ndUNEGNtiUmDYbao2iG9+ibQF5RLGXzQnbZsYR5b3ZtRXDl39hdFtNfb6O/Pek8c0w9I9kvMMMDO5QLY4cNTWbZ7wf++Zh77gPd3LNye+3H/0gZUbgNs6/mzmkQ6LTD17bYozOMTJW2HPSYY/cuxfREu78CGiBqM3O9dVWdPYbH/6e1jvHD54Hj0CA1zXj+WNj3hP3KzBWk3cdPt6xTT+N+MqHZRUXz+/dXuq2xnnwoeax6k/NYcmpkAig== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:52 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 14/39] dyndbg: update default trace destination on reopen Date: Sun, 11 Feb 2024 00:49:44 +0100 Message-ID: <20240210235009.2405808-15-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558082913212335 X-GMAIL-MSGID: 1790558082913212335 The change updates default trace destination when a user requests to open '0' ('0' writes debug logs to global trace-events buffer /sys/kernel/tracing/trace) or open an already opened trace instance. Signed-off-by: Ɓukasz Bartosik --- lib/dynamic_debug.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f41b0b0c8b47..f91c51234456 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -354,10 +354,21 @@ static void update_tr_default_dst(int trace_dst) static int handle_trace_open_cmd(const char *arg) { struct dd_private_tracebuf *buf; - int idx, ret = 0; + int idx = 0, ret = 0; mutex_lock(&ddebug_lock); + /* + * request to open '0' or an already opened trace instance + * results in update of default trace destination + */ + if (!strcmp(arg, DD_TR_EVENT)) + goto update; + + idx = find_tr_instance(arg); + if (idx >= 0) + goto update; + /* bit 0 is not used, reserved for trace prdbg and devdbg events */ idx = find_next_zero_bit(trc_tbl.bmap, trc_tbl.bmap_size, 1); if (idx == trc_tbl.bmap_size) { @@ -371,12 +382,6 @@ static int handle_trace_open_cmd(const char *arg) goto end; } - if (find_tr_instance(arg) >= 0) { - pr_err("instance is already opened name:%s\n", arg); - ret = -EEXIST; - goto end; - } - buf = &trc_tbl.buf[idx]; buf->name = kstrdup(arg, GFP_KERNEL); if (!buf->name) { @@ -402,6 +407,7 @@ static int handle_trace_open_cmd(const char *arg) buf->use_cnt = 0; set_bit(idx, trc_tbl.bmap); v3pr_info("opened trace instance idx=%d, name=%s\n", idx, arg); +update: update_tr_default_dst(idx); end: mutex_unlock(&ddebug_lock);