Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp224910pxj; Wed, 16 Jun 2021 00:35:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfQbxbn28oipYtJe2/chgv5z2LmigZ3UqmNGZb8qLBef78PeFCW8sERqKnsgLKH5bDivdw X-Received: by 2002:a02:9692:: with SMTP id w18mr2969622jai.65.1623828948949; Wed, 16 Jun 2021 00:35:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623828948; cv=none; d=google.com; s=arc-20160816; b=QIjEQFesARtCH+l5ZfhkT3iGRNbBa/YruCoS1XydfmCfzjG61kDiNCKXNVS/HxeNpd Rl5x1Rgmi09cLlzhLQZGSKOPlGu/sSsHqo7A3Hy8wT7Ns91urKDc+5LfkzBgfLn3bzDP +bXMt4z1yCsPSyjpfrn7u+lP4WACSJQaeWwwviBWrJToU47qxMRGOZ/OWWqZ7238l0zb 8VpzaCOCoRMfaEAo9kMu6NIIZzb8xvZlYY6L30ni3Zk/hOfPx7+uI0O/vL12eBMJ128p iY2psUIuzzpeHm7D/4n1/zc1/wSGwFBgU3PkE4RQpD5vRLTPqQvj2L3R1wJ/xHAlBjpx q9FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DkOyAc/bX03Ji647TARVlGet/gKH2IOLf7LbuAqbisM=; b=uBn2NtVmHB9yaqLx7eblgynlHC9EBR1tMbjLdgJdE/kWBNCKOzekdee5rngb+8raN0 sp9rN5Tl9/e4QdPM5PV0s+8w0/feb0v3y6B3qohF56d1OOcQN9bRPz37Q4TFPtNM4D9c 5KZ2ryGYId+c4Glp0QHjF3Sc+3ExttIdQvq4FtaGQ4tjPS7oCgq2Kvd7KlJexAvrhxLQ G1FrX+xLg2/Z6g6JcZNz1DOAJm/Y5fPHNL4SzkbTeeUowbRpxG4+9gDvVUd2vsFgxkn5 laJ18DHDzsPdYVmBwJ1XmXmtnOYYEXZlh2KJF2ZxFypg9s7RUFqGYsnoRJ8YqEcak4y+ 5rfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=qChz5fhq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si1521912ilq.117.2021.06.16.00.35.36; Wed, 16 Jun 2021 00:35:48 -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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=qChz5fhq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231468AbhFPHgk (ORCPT + 99 others); Wed, 16 Jun 2021 03:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231179AbhFPHgj (ORCPT ); Wed, 16 Jun 2021 03:36:39 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C0E8C061574 for ; Wed, 16 Jun 2021 00:34:33 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id q5so1482092wrm.1 for ; Wed, 16 Jun 2021 00:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DkOyAc/bX03Ji647TARVlGet/gKH2IOLf7LbuAqbisM=; b=qChz5fhqUDfjnLDvqzi5XBuBjS/YpqGv52c5EDCSZUyUKBmckNmzxhBCgGZfu/ywnG xjGGlfmbYpVUwHDcsUi9cx2/ycQeOpnPR2oxzqsb5O+GIv9OQPAK9U/THRXX0QGPzUmn 5PtWtI8i7nwiij7U3ef1cvW+85/WV64Mr0G7tiGz8LRaxbPgLtjStCIt6FjbG5M7GdBU uD8DEBAqhZiSmI22kl8Z7BHs5eoClErpyIa+oQkopS5ezeu31Wx1j5ZhPkJpH6CZi6Kw gamYMqgtCxRykk/RF6YbF94x0EsbHR+usC+AIeXFhUb8RZFdRMbiRkUjSFh6WHxM16kg Wh2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DkOyAc/bX03Ji647TARVlGet/gKH2IOLf7LbuAqbisM=; b=n3NB3yrNP+8tiEzmCj6L8y2bmGOlthTuonURD16quVGzMeUkYx1FYprhzCmYKdDT7T /95Nv+/RKJ2tItxlBMHrqq0+ioFJOXME/0fnJN21GzY/Cplr9aRFCh92WqgpCdVI3c83 1sySD8TfI2GCATBSFl/DUjXKVi/rzLUk27688kH2Rz1Wki9wVqzEOm8w52ae+XsxB2Xn LfE+M56LwDBDJJ7OwOg5n/lOAMxGliXhv6IdiL/siks4Jraz4gusjHuzP5YDYTE7Et/u yKF6RtFSmTyfZrE8Fpxpjy+RmEcYzuJ3S+Jj/paAp5YCbuR0wjIZs4sYzvtBmgmJpuqk 0xFg== X-Gm-Message-State: AOAM533M/Jd6BwjB4TCjZb4KI/E4UagO64E2QOF3+1DhlfFqCUNG/EWK He5K6NkAHftwL6A/W4neVnWsiU4Xn1N9N9V+UFrezQ== X-Received: by 2002:a05:6000:1889:: with SMTP id a9mr3682588wri.288.1623828871959; Wed, 16 Jun 2021 00:34:31 -0700 (PDT) MIME-Version: 1.0 References: <20210611124642.72910-1-zhengqi.arch@bytedance.com> <06292162-5a44-6f91-140d-e1211c006ad0@kernel.org> In-Reply-To: <06292162-5a44-6f91-140d-e1211c006ad0@kernel.org> From: =?UTF-8?B?6YOR55Cm?= Date: Wed, 16 Jun 2021 15:34:21 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] x86: fix get_wchan() not support the ORC unwinder To: Andy Lutomirski Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, peterz@infradead.org, x86@kernel.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 15, 2021 at 12:21 AM Andy Lutomirski wrote: > > On 6/11/21 5:46 AM, Qi Zheng wrote: > > Currently, the kernel CONFIG_UNWINDER_ORC option is enabled by > > default on x86, but the implementation of get_wchan() is still > > based on the frame pointer unwinder, so the /proc//wchan > > always return 0 regardless of whether the task is running. > > > > We reimplement the get_wchan() by calling stack_trace_save_tsk(), > > which is adapted to the ORC and frame pointer unwinders. > > How much slower does this make ps? I used the bpftrace tool to test the running time of get_wchan() in the two cases of the ORC and frame pointer unwinders, the test script and the result are as follows: the test script: bpftrace -e 'kprobe:get_wchan { @start[tid] = nsecs; } kretprobe: get_wchan /@start[tid]/ { @ns[comm] = hist(nsecs - @start[tid]); delete(@start[tid]); }' the result: 1) ORC unwinder ( before applying this patch ) @ns[ps]: [512, 1K) 4609 |@@@@@@@@@@@@ | [1K, 2K) 18599 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [2K, 4K) 1848 |@@@@@ | [4K, 8K) 307 | | [8K, 16K) 74 | | [16K, 32K) 12 | | 73% of the cases are in the [1K, 2K) range. Notice: In this case, the get_wchan() always returns the wrong value of 0. 2) ORC unwinder ( after applying this patch ) @ns[ps]: [512, 1K) 536 |@ | [1K, 2K) 19945 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [2K, 4K) 5604 |@@@@@@@@@@@@@@ | [4K, 8K) 246 | | [8K, 16K) 154 | | [16K, 32K) 18 | | 75% of the cases are in the [1K, 2K) range. 3) frame point unwinder ( before applying this patch ) @ns[ps]: [512, 1K) 245 | | [1K, 2K) 16577 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [2K, 4K) 2788 |@@@@@@@@ | [4K, 8K) 190 | | [8K, 16K) 74 | | [16K, 32K) 9 | | 83% of the cases are in the [1K, 2K) range. 4) frame point unwinder ( after applying this patch ) @ns[ps]: [512, 1K) 85 | | [1K, 2K) 12023 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| [2K, 4K) 7418 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | [4K, 8K) 232 |@ | [8K, 16K) 104 | | [16K, 32K) 18 | | 60% of the cases are in the [1K, 2K) range. In summary, the running time of get_wchan() has increased after applying this patch. But the get_wchan() is not the hotspot function, and this is a bug in the default ORC option, so I think these increased runtimes are acceptable. In addition, this issue has existed for nearly 4 years and no one has fixed it, if nobody cares about the return value of the get_wchan(), maybe we can return 0 or remove this function directly. What do you think? Best regards, Qi Zheng > > --Andy