Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp671210rwb; Fri, 2 Sep 2022 23:54:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4CFp2eou2yuGQkqWG6naPDw+a/7zDxW1Y88+lrc/CpzF50k/05qNkmlhxqZ/5v26n3JvnG X-Received: by 2002:a50:eb48:0:b0:448:931e:e215 with SMTP id z8-20020a50eb48000000b00448931ee215mr21563963edp.305.1662188080939; Fri, 02 Sep 2022 23:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662188080; cv=none; d=google.com; s=arc-20160816; b=KYgT9kap0rrxETXBTh3+1vUmxNriZMubDdMkjgUQYmes6opcxnSUNaonT6KA+xWdNQ kt2kGDExewCMItUwokEeFZPXp+o1PQuDWM4T9yK3lE0/pYLDqAJJv/qndv1rw4MRCF/s xCWmQqFmuKWhfL/yYf+CaSuHiUWucpEByDY73icTXeAfefuDcYdjgs+Atui6IR1tgQJY KejJoS3AgIZMReDr5CrFOCdV/ekem/bAuM2eUazYItHsuXjVZzElB8EBQ5mbe1PpMtIm GuHKzE1FacSHAAJ9djj0jq/S5LNX2rEIs9KWzttCzROe1qiz08YsmXxba+Lpl0YbSmB4 llDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zZUo4Yh/oc1vNFvxaSNW3YUhPsCaAqVSFhhyRBZevNo=; b=S015wSc+cWkw2yhXuC40gwNj91RkEiehVxY5kDFxfQ9Hoki3pyKek8t+4j17XM0pMl SefXA39wNGW8D75RLgju9MWhrvv26+7d9xOTQQxoY0xViJ8Uq82VSCMtKWC1SMLTISRF dSmeuRDi3QFN8TNRI6HUalwLjXH67w9UhsoH6koeTc+FVknauGcsJ9HJR1SMhbvgM1Mj ylCzsV61KIJkJw7GAsrOuJ7X2WnvtE3enmnGgLchvRiPbTJmR9v2TpyT5sCVHr4V3lw3 5tfSxFjt3Yl7uwahomGafConL0ppqQf3lWy108INLDxHObe1Ph375id1xq/yxKwpQ2Zm HHwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DamoIUL9; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb16-20020a1709071c9000b0073d99832c34si3660987ejc.778.2022.09.02.23.54.15; Fri, 02 Sep 2022 23:54:40 -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=@redhat.com header.s=mimecast20190719 header.b=DamoIUL9; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232257AbiICGnk (ORCPT + 99 others); Sat, 3 Sep 2022 02:43:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232557AbiICGni (ORCPT ); Sat, 3 Sep 2022 02:43:38 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F1BDB1B85 for ; Fri, 2 Sep 2022 23:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662187417; 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; bh=zZUo4Yh/oc1vNFvxaSNW3YUhPsCaAqVSFhhyRBZevNo=; b=DamoIUL9h9qYs5IKVh6UDPuDoTuTNaRyf+rvMfvT4hGJE3sbAZsGJsHsSdV6Run1unsHR6 MFawp4SgvWecQZP8Ofyuft1Ns+F+XnvLhoYNI3+e0PhM5roLeIkb3C1QBJa4CcShVhYPZ8 knEIwlxIfc5/G880ppsC/nLRTTGe3dU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-435-Sqaui8VDPACHMNd1m7TfYg-1; Sat, 03 Sep 2022 02:43:33 -0400 X-MC-Unique: Sqaui8VDPACHMNd1m7TfYg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88DE8805B9A; Sat, 3 Sep 2022 06:43:32 +0000 (UTC) Received: from localhost (unknown [10.40.192.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FAFAC15BBD; Sat, 3 Sep 2022 06:43:31 +0000 (UTC) From: Oleksandr Natalenko To: linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jonathan Corbet , Alexander Viro , Andrew Morton , Huang Ying , "Jason A . Donenfeld" , Will Deacon , "Guilherme G . Piccoli" , Laurent Dufour , Stephen Kitt , Rob Herring , Joel Savitz , "Eric W . Biederman" , Kees Cook , Xiaoming Ni , Luis Chamberlain , =?UTF-8?q?Renaud=20M=C3=A9trich?= , Oleg Nesterov , Grzegorz Halat , Qi Guo Subject: [PATCH] core_pattern: add CPU specifier Date: Sat, 3 Sep 2022 08:43:30 +0200 Message-Id: <20220903064330.20772-1-oleksandr@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Statistically, in a large deployment regular segfaults may indicate a CPU issue. Currently, it is not possible to find out what CPU the segfault happened on. There are at least two attempts to improve segfault logging with this regard, but they do not help in case the logs rotate. Hence, lets make sure it is possible to permanently record a CPU the task ran on using a new core_pattern specifier. Suggested-by: Renaud Métrich Signed-off-by: Oleksandr Natalenko --- Documentation/admin-guide/sysctl/kernel.rst | 1 + fs/coredump.c | 5 +++++ include/linux/coredump.h | 1 + 3 files changed, 7 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index 835c8844bba48..b566fff04946b 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -169,6 +169,7 @@ core_pattern %f executable filename %E executable path %c maximum size of core file by resource limit RLIMIT_CORE + %C CPU the task ran on % both are dropped ======== ========================================== diff --git a/fs/coredump.c b/fs/coredump.c index a8661874ac5b6..166d1f84a9b17 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -325,6 +325,10 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm, err = cn_printf(cn, "%lu", rlimit(RLIMIT_CORE)); break; + /* CPU the task ran on */ + case 'C': + err = cn_printf(cn, "%d", cprm->cpu); + break; default: break; } @@ -535,6 +539,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) */ .mm_flags = mm->flags, .vma_meta = NULL, + .cpu = raw_smp_processor_id(), }; audit_core_dumps(siginfo->si_signo); diff --git a/include/linux/coredump.h b/include/linux/coredump.h index 08a1d3e7e46d0..191dcf5af6cb9 100644 --- a/include/linux/coredump.h +++ b/include/linux/coredump.h @@ -22,6 +22,7 @@ struct coredump_params { struct file *file; unsigned long limit; unsigned long mm_flags; + int cpu; loff_t written; loff_t pos; loff_t to_skip; -- 2.37.2