Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21FD4C433E0 for ; Wed, 5 Aug 2020 18:36:05 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C134A22CF7 for ; Wed, 5 Aug 2020 18:36:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NdS9X2dX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C134A22CF7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1k3OFy-0004d7-3u; Wed, 05 Aug 2020 14:35:18 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1k3OCl-00026G-61 for kernelnewbies@kernelnewbies.org; Wed, 05 Aug 2020 14:32:00 -0400 Received: by mail-ot1-x344.google.com with SMTP id t7so20291841otp.0 for ; Wed, 05 Aug 2020 11:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=010+IYceHrmiSE0RYy4Am/BLcfjqbtLe+RYcNDaxNG0=; b=NdS9X2dXfnTHHmeEUNgkBaNpSPT+cuAOu1mFMBSA9rNBmP7D2xSF0GLu+S6zM9kOVR 4LInT+Cu4PXzevbHY8djZ6/F9xdKY6/PNv6PJYt5utqYpiiQ/Z4gg0HXGtoPdLhkaZZI POaFV+wRuVUv0sOiQofDqPaiG7MsEogJqU3r2dIPSYhmTE4jYLEfYEsqsSfoE1QbF1ku PLK6YgGd9820N9t2YVosHj24jU1p4VSPVpv0jqFWTneZDnAH+SAZIQMErsYuIjdA3bXh M2pV48WNXkoljrjylhwz5XGC9KGXkDPMeg3S8leq/UBbicH01uCExYV99f3NuvRkzpkb WKzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=010+IYceHrmiSE0RYy4Am/BLcfjqbtLe+RYcNDaxNG0=; b=gBE5zk68yujuGJjzVAfdDfA7ad6pWkgvoVxvDO6KDB13BauJQkWo+t20d9UZ6fSxB1 l3jMjxRX3pFjGsYFVmmyeHhR1qi0H1bqsZfG7PYyooDZsGzfO32zvwaHKQcqhKfcn0ct tMk+DtpsKUdwrO0oMVGmqTRpG37L9yxAqSfpobrFABLVtUD9Tei0Oyjz+9LhGk2L9Rx4 finGY3GcYrSMWAHMu5x3Xcf2krsRw6u1QAJm6fSdXieU5xjHe2lMQ7k8Ttrf9bCd+41H zY61bz6z3EOceLrFb9tSBiX6dRTEF4ShVMqt4VmR22Fb+bVIEuDLulZS9AQYC3qnUiRM tUzw== X-Gm-Message-State: AOAM531OzL65niOiks+o96uAzTaD0tGdwkrj28VHvbG3TuPohXeTHmF4 JkHFVQajL3300lz8wMZhUvG2YFY2rbM= X-Google-Smtp-Source: ABdhPJy8JGx/Pkv3i481X5RxNXweaTVhMGu47hI4xJGCf2q8ZqDabr7FkGbr3kFoY03x7/RUx9O3jg== X-Received: by 2002:a05:6830:1b79:: with SMTP id d25mr3647365ote.107.1596652249242; Wed, 05 Aug 2020 11:30:49 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:6ba0::1eb0]) by smtp.googlemail.com with ESMTPSA id t83sm596948oot.22.2020.08.05.11.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 11:30:48 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com Subject: [PATCH 7/8] dyndbg: enable 'cache' of active pr_debug callsites Date: Wed, 5 Aug 2020 12:30:22 -0600 Message-Id: <20200805183023.586590-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200805183023.586590-1-jim.cromie@gmail.com> References: <20200805183023.586590-1-jim.cromie@gmail.com> MIME-Version: 1.0 Cc: Jim Cromie , kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org in ddebug_zpool_put() dont zs_unmap the callsite, if it is enabled for printing. This will eliminate possibly repeated un-maps then re-maps of enabled and invoked pr-debug callsites, and will promptly retire all other uses. Unfortunately this causes mysterious problems: (needs more editing down) [jimc@frodo build-v2]$ gdb -x cmds vmlinux GNU gdb (GDB) Fedora 9.1-5.fc32 ... Reading symbols from vmlinux... 0x000000000000fff0 in exception_stacks () Hardware assisted breakpoint 1 at 0xffffffff82c2de50: file ../lib/dynamic_debug.c, line 1164. Breakpoint 1, ddebug_zpool_init () at ../lib/dynamic_debug.c:1164 1164 dd_callsite_zpool = zs_create_pool("dyndbg_callsites"); at ../include/linux/compiler.h:352 --Type for more, q to quit, c to continue without paging-- Num Type Disp Enb Address What 1 hw breakpoint keep y 0xffffffff82c2de50 in ddebug_zpool_init at ../lib/dynamic_debug.c:1164 breakpoint already hit 1 time (gdb) l 1159 static void __init ddebug_zpool_init(void) 1160 { 1161 struct _ddebug *iter; 1162 1163 /* tbd- no corresponding destroy */ 1164 dd_callsite_zpool = zs_create_pool("dyndbg_callsites"); 1165 if (!dd_callsite_zpool) { 1166 pr_err("create pool failed\n"); 1167 return; 1168 } (gdb) l 1169 1170 /* add-module normally does this, but not in time for builtins */ 1171 for (iter = __start___dyndbg; iter < __stop___dyndbg; iter++) 1172 ddebug_zpool_add(iter); 1173 1174 v2pr_info("total pages: %lu compaction: %lu\n", 1175 zs_get_total_pages(dd_callsite_zpool), 1176 zs_compact(dd_callsite_zpool)); 1177 } 1178 late_initcall(ddebug_zpool_init); (gdb) b 1174 Breakpoint 2 at 0xffffffff82c2de9b: file ../lib/dynamic_debug.c, line 1174. (gdb) c Continuing. Breakpoint 2, ddebug_zpool_init () at ../lib/dynamic_debug.c:1174 1174 v2pr_info("total pages: %lu compaction: %lu\n", (gdb) n do_one_initcall (fn=0xffffffff82c2de50 ) at ../init/main.c:1200 1200 do_trace_initcall_finish(fn, ret); (gdb) 1204 if (preempt_count() != count) { (gdb) 26 return raw_cpu_read_4(__preempt_count) & ~PREEMPT_NEED_RESCHED; (gdb) 1208 if (irqs_disabled()) { (gdb) 164 return !(flags & X86_EFLAGS_IF); (gdb) 1212 WARN(msgbuf[0], "initcall %pS returned with %s\n", fn, msgbuf); (gdb) do_initcall_level (command_line=, level=) at ../init/main.c:1271 (gdb) info break Num Type Disp Enb Address What 1 hw breakpoint keep y 0xffffffff82c2de50 in ddebug_zpool_init at ../lib/dynamic_debug.c:1164 breakpoint already hit 1 time 2 breakpoint keep y 0xffffffff82c2de9b in ddebug_zpool_init at ../lib/dynamic_debug.c:1174 breakpoint already hit 1 time (gdb) bt (gdb) up 1288 do_initcall_level(level, command_line); (gdb) up 1308 do_initcalls(); (gdb) return Can not force return from an inlined function. (gdb) b Breakpoint 3 at 0xffffffff82bfe1c6: file ../include/linux/compiler.h, line 352. (gdb) c Continuing. Breakpoint 3, offset_to_ptr (off=) at ../include/linux/compiler.h:352 352 return (void *)((unsigned long)off + *off); (gdb) n do_initcall_level (command_line=, level=) at ../init/main.c:1271 1271 for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) (gdb) Breakpoint 3, offset_to_ptr (off=) at ../include/linux/compiler.h:352 352 return (void *)((unsigned long)off + *off); (gdb) do_initcall_level (command_line=, level=) at ../init/main.c:1271 1271 for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) (gdb) Breakpoint 3, offset_to_ptr (off=) at ../include/linux/compiler.h:352 352 return (void *)((unsigned long)off + *off); (gdb) do_initcall_level (command_line=, level=) at ../init/main.c:1271 1271 for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) (gdb) do_initcalls () at ../init/main.c:1285 1285 for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) { (gdb) 1291 kfree(command_line); (gdb) kernel_init_freeable () at ../init/main.c:1507 1507 console_on_rootfs(); (gdb) 1514 if (!ramdisk_execute_command) (gdb) 1515 ramdisk_execute_command = "/init"; (gdb) 1517 if (ksys_access((const char __user *) (gdb) 1519 ramdisk_execute_command = NULL; (gdb) 1520 prepare_namespace(); (gdb) 1532 integrity_load_keys(); (gdb) kernel_init (unused=) at ../init/main.c:1401 1401 async_synchronize_full(); (gdb) 1403 free_initmem(); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1404 mark_readonly(); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1410 pti_finalize(); (gdb) bt (gdb) info break Num Type Disp Enb Address What 1 hw breakpoint keep y 0xffffffff82c2de50 in ddebug_zpool_init at ../lib/dynamic_debug.c:1164 breakpoint already hit 1 time 2 breakpoint keep y 0xffffffff82c2de9b in ddebug_zpool_init at ../lib/dynamic_debug.c:1174 breakpoint already hit 1 time 3 breakpoint keep y 0xffffffff82bfe1c6 ../include/linux/compiler.h:352 breakpoint already hit 7 times (gdb) info break 3 Num Type Disp Enb Address What 3 breakpoint keep y 0xffffffff82bfe1c6 ../include/linux/compiler.h:352 breakpoint already hit 7 times (gdb) n Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1412 system_state = SYSTEM_RUNNING; (gdb) n Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1413 numa_default_policy(); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1415 rcu_end_inkernel_boot(); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1417 do_sysctl_args(); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1419 if (ramdisk_execute_command) { (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1433 if (execute_command) { (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1434 ret = run_init_process(execute_command); (gdb) l 1429 * 1430 * The Bourne shell can be used instead of init if we are 1431 * trying to recover a really broken machine. 1432 */ 1433 if (execute_command) { 1434 ret = run_init_process(execute_command); 1435 if (!ret) 1436 return 0; 1437 panic("Requested init %s failed (error %d).", 1438 execute_command, ret); (gdb) s Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. run_init_process (init_filename=0xffff888007fd6525 "/bin/sh") at ../init/main.c:1324 1324 argv_init[0] = init_filename; (gdb) n Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1325 pr_info("Run %s as init process\n", init_filename); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1326 pr_debug(" with arguments:\n"); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1327 for (p = argv_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1328 pr_debug(" %s\n", *p); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1327 for (p = argv_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1328 pr_debug(" %s\n", *p); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1327 for (p = argv_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1328 pr_debug(" %s\n", *p); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1327 for (p = argv_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1329 pr_debug(" with environment:\n"); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1330 for (p = envp_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1331 pr_debug(" %s\n", *p); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1330 for (p = envp_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1331 pr_debug(" %s\n", *p); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1330 for (p = envp_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1331 pr_debug(" %s\n", *p); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1330 for (p = envp_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1331 pr_debug(" %s\n", *p); (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1330 for (p = envp_init; *p; p++) (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1332 return do_execve(getname_kernel(init_filename), (gdb) Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. kernel_init (unused=) at ../init/main.c:1435 1435 if (!ret) (gdb) n Cannot remove breakpoints because program is no longer writable. Further execution is probably impossible. 1437 panic("Requested init %s failed (error %d).", (gdb) Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 102f47b2a439..9c51f24a9c66 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -174,7 +174,9 @@ static void ddebug_callsite_put(struct _ddebug *dp) /* no site to unmap, or no means to restore */ return; - /* always unmap for now. if !pr-debug was too hard */ + if (dp->flags & _DPRINTK_FLAGS_PRINT) + return; /* keep maps of enabled pr_debugs */ + zs_unmap_object(dd_callsite_zpool, dp->zhandle); dp->site = NULL; } -- 2.26.2 _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies