Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3999614pxf; Tue, 6 Apr 2021 05:47:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi8HYJrwYs2meESRRy+16qGBdeo9kaYqjoaTGxmj1+HUVeahIpcPKOuozaF3x3jxLFOR3s X-Received: by 2002:aa7:d3c1:: with SMTP id o1mr7888189edr.153.1617713250907; Tue, 06 Apr 2021 05:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617713250; cv=none; d=google.com; s=arc-20160816; b=zxUSYiDpTUuxcCIfY8hwhBbrRhoSw1I/uyToiOkLLgKuIfb2+sVMveAriWJfdzM3rI ODMmf8iqE8Cqx4/yGEG0niUxXwbdKkjNsDhcsUc6qblSmqwWRr8Hy0JF43/dOH2PcDKa AsN5Mr1qlBl8HXOpARWiwAzKDogIr4wMfZcM8EKvn1Sgin2qdpL9TWGgedMlfTGC3vLA V2bs7NV2QuQ8dXXnG0ubQvDJTHmefZOsvIv6eAtG104l7SpWmCNIvc61KtKbEV7SdKq4 QkavPNvuO9R7a6nIHng+CGZOKH5wc8LPhk3xqQIEw0gBABV4jnD6PyjnuMGNhvXcRi/5 r1pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=KO7YOZGHuv1kVdP1LMRNzdDPgf6i9D7Y3FicCdhas5c=; b=YMJEx7fm5MdwL72MS3GSzeSeZQIHREC20ssQDGIPMAsq3msWWSWQQNOBEwLbBjGGhC NEHdrsFs1l42LVVaVbTbSR8aM9JyunfQM2LiL0K5VJQasM6PAJrLaW5SBUVl4dlovfri U4IjxOrOFJUMxdqAvMW3hVCmo/ZR7QMa3ajvDjfjawcmmXYM7I/YKjoxFOzg6pym/B25 fJ7u/lmN3CKzbQS8MHSDWZeruhdma/CNh6bA2VjmO7DvDsL66B6dc/f61m4CRRvPMq1E T3hLRX6+aYa0TbX8hsN/0LCv1EZPbp+TXBdmS7A5A7SvDIp4+AuSuGgsW6HNWBTLsTnF VDJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R8hC4wF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t15si17665366ejx.751.2021.04.06.05.47.05; Tue, 06 Apr 2021 05:47:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R8hC4wF7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S243248AbhDFB53 (ORCPT + 99 others); Mon, 5 Apr 2021 21:57:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24827 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239052AbhDFB52 (ORCPT ); Mon, 5 Apr 2021 21:57:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617674241; 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=KO7YOZGHuv1kVdP1LMRNzdDPgf6i9D7Y3FicCdhas5c=; b=R8hC4wF7jblD92qK0beLPGzzjbJrryH0LlDhbEcmKUweT8vT5z7mgORAsM6zORhV9wVWW0 6DrdXYI9BF4JxIlIZfrWEeH5PaBYSiorc/fNaSSSpqH+GXOoYtb2MjjJu+D4hSt8wjwz3H Hjte5cZlZ/YPKj+RmKMtyTB2YJC2+Xs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-483-StJ_PWVtMb2bOXS4wMmrlQ-1; Mon, 05 Apr 2021 21:57:17 -0400 X-MC-Unique: StJ_PWVtMb2bOXS4wMmrlQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0470D180FCA7; Tue, 6 Apr 2021 01:57:16 +0000 (UTC) Received: from llong.remote.csb (ovpn-112-77.rdu2.redhat.com [10.10.112.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39F40610A8; Tue, 6 Apr 2021 01:57:08 +0000 (UTC) Subject: Re: [PATCH v4] sched/debug: Use sched_debug_lock to serialize use of cgroup_path[] only To: Steven Rostedt Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Bharata B Rao , Phil Auld , Daniel Thompson , linux-kernel@vger.kernel.org References: <20210405234203.23526-1-longman@redhat.com> <20210405201807.4ee7778d@gandalf.local.home> From: Waiman Long Organization: Red Hat Message-ID: <5c4d0d47-5503-76a2-0f27-1b4b13c34aa5@redhat.com> Date: Mon, 5 Apr 2021 21:57:07 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210405201807.4ee7778d@gandalf.local.home> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/5/21 8:18 PM, Steven Rostedt wrote: > On Mon, 5 Apr 2021 19:42:03 -0400 > Waiman Long wrote: > >> +/* >> + * All the print_cpu() callers from sched_debug_show() will be allowed >> + * to contend for sched_debug_lock and use group_path[] as their SEQ_printf() >> + * calls will be much faster. However only one print_cpu() caller from >> + * sysrq_sched_debug_show() which outputs to the console will be allowed >> + * to use group_path[]. Another parallel console writer will have to use >> + * a shorter stack buffer instead. Since the console output will be garbled >> + * anyway, truncation of some cgroup paths shouldn't be a big issue. >> + */ >> +#define SEQ_printf_task_group_path(m, tg, fmt...) \ >> +{ \ >> + unsigned long flags; \ >> + int token = m ? TOKEN_NA \ >> + : xchg_acquire(&console_token, TOKEN_NONE); \ >> + \ >> + if (token == TOKEN_NONE) { \ >> + char buf[128]; \ >> + task_group_path(tg, buf, sizeof(buf)); \ >> + SEQ_printf(m, fmt, buf); \ >> + } else { \ >> + spin_lock_irqsave(&sched_debug_lock, flags); \ >> + task_group_path(tg, group_path, sizeof(group_path)); \ >> + SEQ_printf(m, fmt, group_path); \ >> + spin_unlock_irqrestore(&sched_debug_lock, flags); \ >> + if (token == TOKEN_ACQUIRED) \ >> + smp_store_release(&console_token, token); \ >> + } \ >> } >> #endif > And you said my suggestion was complex! > > I'll let others review this. > This patch is actually inspired by your suggestion, though it is structured differently from your approach. I really want to thank you for your valuable feedback. I realized that printing to a sequence file wasn't really a problem, only printing to console can be problematic. That is why I decided to allow unlimited use of group_path[] for those users and only one console writer is allowed to use it. As for calling touch_nmi_watchdog(), I am still thinking where will be the right place to do it, but it can be done with a separate patch, if needed. Cheers, Longman