Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5293298rwb; Tue, 6 Sep 2022 23:53:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR50m6gXP1rQclLISlAQgSNOwNtArhMccUlWrrcKSpUfFRuHBLah9OjKGPC4s8ZtLacrtAHU X-Received: by 2002:a65:6bd3:0:b0:42b:9117:b9d1 with SMTP id e19-20020a656bd3000000b0042b9117b9d1mr2214926pgw.238.1662533603072; Tue, 06 Sep 2022 23:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662533603; cv=none; d=google.com; s=arc-20160816; b=K3G9ddoLBzvfTvxRhElaYT7mCXbcOFg8+rIYMM/9pDkbGKgApwdxk/RujZByZ8JDLQ PoGNLtz4OvywwqcA6Vj8cqC7hO315TOCzVQmNm94408ZAIEtytqGnuRF7tGqqD1xzzVZ yjNjsZL32GgcGWwk/yYVEr79r9XPREFKP/FaEG8sOHFYdUGroInzigaYsTJxHa9wz3G8 khn/HhpRQIL3TN7br7sL/zY05Yp6P1BeIkOoHL4GQ4uNB6gGGIfeRhPL4pEYmwlvdBcE iQtq9+p5emw/Q+HxB5hr3AwRgnbh/+iXoZVhucZZ+nHpL8vonsKTBimXNYBJf++Egeoo OBKQ== 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 :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature; bh=4az1HQKb/HIdHmleJaWvrZvYTAApZUEhXiynTldmky0=; b=jRsu7HMAQ48L488c3UkcUldoil0AzpF7+buum9jyCkt+09efxIK4z9XdK3MKXSLsxc Z1f8giyBsndoQl3BGLZyMV2oncRrsGEPrVEStnqtoQT+hn2q+6iJ17H6GVM54qF2TNlM Pbp7awnyE0q7ojhfevLL3nwuNuCjOthd3CANVMV4Byxq8bYcL60zsX85fBu/0SEzZ519 zFb7AgWAgoVuCd7InYFdlDnSQxZ3hQ87ob3IsIpN2mssij33RtPoYXao3AdpBlV0DOPk oxOaXitPRdAh+X6DY6bEOqIS5l89/JmHRpf9DmkqNWqrUfQijbCjBl4CuFXTKFi7Oort nkQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L2dCa7MR; 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 y8-20020a17090322c800b00174a017ebb9si17021754plg.190.2022.09.06.23.53.11; Tue, 06 Sep 2022 23:53:23 -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=L2dCa7MR; 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 S229461AbiIGGPZ (ORCPT + 99 others); Wed, 7 Sep 2022 02:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbiIGGPX (ORCPT ); Wed, 7 Sep 2022 02:15:23 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D6637436E for ; Tue, 6 Sep 2022 23:15:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662531318; 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=4az1HQKb/HIdHmleJaWvrZvYTAApZUEhXiynTldmky0=; b=L2dCa7MRfTGgcFSHH+hPxjj3KmjIT7Nhg2hyllNa3KMdtE/Qa6xga6O5oAVM/w4j0Nwxak 1uWBVOpnikMfufBSNowZ9Gg/SDsBUb/bwJWjlgXDhx+F4w+5roXLtprHsIO6oQ9BX10qWt Iorq3uiTTTqAkwDeniicZFmQMRk91T4= 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-154-9K7eDHMfMX-BuslO2rMT6A-1; Wed, 07 Sep 2022 02:15:12 -0400 X-MC-Unique: 9K7eDHMfMX-BuslO2rMT6A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13407811E87; Wed, 7 Sep 2022 06:15:12 +0000 (UTC) Received: from butterfly.localnet (unknown [10.40.192.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9035540CF916; Wed, 7 Sep 2022 06:15:07 +0000 (UTC) From: Oleksandr Natalenko To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, 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 , Kees Cook , Xiaoming Ni , Luis Chamberlain , Renaud =?ISO-8859-1?Q?M=E9trich?= , Oleg Nesterov , Grzegorz Halat , Qi Guo Subject: Re: [PATCH] core_pattern: add CPU specifier Date: Wed, 07 Sep 2022 08:15:06 +0200 Message-ID: <5599808.DvuYhMxLoT@redhat.com> Organization: Red Hat In-Reply-To: <87r10ob0st.fsf@email.froward.int.ebiederm.org> References: <20220903064330.20772-1-oleksandr@redhat.com> <87r10ob0st.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 Hello. On st=C5=99eda 7. z=C3=A1=C5=99=C3=AD 2022 0:22:42 CEST Eric W. Biederman w= rote: > Oleksandr Natalenko writes: >=20 > > Statistically, in a large deployment regular segfaults may indicate a C= PU issue. > > > > Currently, it is not possible to find out what CPU the segfault happene= d on. > > There are at least two attempts to improve segfault logging with this r= egard, > > 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. >=20 > I am puzzled why make it part of the file name, and not part of the > core file? Say an elf note? This might be a good idea too, and one approach doesn't exclude the other o= ne. > The big advantage is that you could always capture the cpu and > will not need to take special care configuring your system to > capture that information. The advantage of having CPU recorded in the file name is that in case of mu= ltiple cores one can summarise them with a simple ls+grep without invoking = a fully-featured debugger to find out whether the segfaults happened on the= same CPU. Thanks. > Eric >=20 > > Suggested-by: Renaud M=C3=A9trich > > 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/Documentatio= n/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 > > =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > > =20 > > 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, s= truct coredump_params *cprm, > > err =3D cn_printf(cn, "%lu", > > rlimit(RLIMIT_CORE)); > > break; > > + /* CPU the task ran on */ > > + case 'C': > > + err =3D cn_printf(cn, "%d", cprm->cpu); > > + break; > > default: > > break; > > } > > @@ -535,6 +539,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) > > */ > > .mm_flags =3D mm->flags, > > .vma_meta =3D NULL, > > + .cpu =3D raw_smp_processor_id(), > > }; > > =20 > > 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; =2D-=20 Oleksandr Natalenko (post-factum) Principal Software Maintenance Engineer