Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3431535pxp; Mon, 14 Mar 2022 20:07:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPOZokdRbhd4n5iL6yN9cCXRAkU1L5vsNPZwpyK7vss3hT8AZWfVuZhb5Q+aSP9WIdZdBc X-Received: by 2002:a50:f68b:0:b0:415:a36c:5c0b with SMTP id d11-20020a50f68b000000b00415a36c5c0bmr22987150edn.272.1647313624010; Mon, 14 Mar 2022 20:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647313624; cv=none; d=google.com; s=arc-20160816; b=1F2Lke30tIN/kmu39KH4GwsJbo0WhX4zCFKe26w2vs2NmTEnyPswWXL9fpdl4cGU4w P5fGkFOQbEnhSTOc+wyysdro7jml9BCd0l/H7KlEoxknwMe6Qh4t1x5rQ2hmR3BmYAkI mQomT7DZnyr45YdmYZiLEfAlX8NdvsDdbSJY5LMjp6F/layWGsCUGhfGlYFl4UqNqryv PI9ueVQjdN2nSGnWhluMtKeCG8cZEa6mYg0Z91mqqhS42ht+l9YPAwL8IWtP81zO5iKn wBi/Af+g4IsC0/7+W6OfB1roAufz6PylTdv5avs5U2AzdDroy6BIJpkBF1eNZTFbLx68 p8mw== 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; bh=wluxvZZRX4EKbcVvJ/eg3d1hoy/ZEcP65mxSGZfR8b8=; b=H6/5gs7OXrIxZ657P2hNcR5RETYKsIDbDpJW/UcZbU0Ej4Uj8MPN69epiShALHuziO lu2P2PWih8pfZYslvWlIdugadAcSN03+kb3WDWE9mIflfoDexXvvd6SCDj33ZcyBgwS3 HpjJe0fhYSNx30cbjGr6A7dibVg99YuKiOC95hLQwV6BcsHR+LYzbyk/O5Ij2qr6wco/ 5FrInABXqxxJUv3UbIXu9+MWel0cXQ3avuwPtnxF22/mlqJozn+L8pLBh+/r0oI+ty6d vuGzClXBVF0Hf8T6efDun24SNg9psoAamp+ps8cnJeKN+bAmuZRox8jb3kn/g3mFUqts Ob6g== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a056402270a00b00416b4e7bf2dsi9606934edd.312.2022.03.14.20.06.35; Mon, 14 Mar 2022 20:07:03 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243389AbiCNRaW (ORCPT + 99 others); Mon, 14 Mar 2022 13:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbiCNRaT (ORCPT ); Mon, 14 Mar 2022 13:30:19 -0400 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55979DEB6; Mon, 14 Mar 2022 10:29:09 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id h11so22992523ljb.2; Mon, 14 Mar 2022 10:29:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wluxvZZRX4EKbcVvJ/eg3d1hoy/ZEcP65mxSGZfR8b8=; b=XbwNDwKpXgp1ZuRwvwpoko54IbbMOYB3f1jXrHsKFNnutQZZNr2zneAW2SgB6xN+qn dN/hzwHJFHB8afHyFrbl6J74UeRKU2KkqC3f/GBNuktY0xYCeR4+UNEToPpvnZ9YW9ut nMvRm/eRguVIFYH9ghX9fnnHD9GVQU8Aek6vb1TPx1aD5nsRHeczjDx+47RaQ6MBYzIo SlFGtgi70yQItdbHaJWwlzzaOfJDoxA5O7tPZ64YFiH9b9pUMIYvTqVgzBvwQLzzSF40 g5VEGw3PqIabA8fMo6+FxNlf2JAQQoP+uUje1WomJBKVCFGx4rjHN2OjsCwu+XydO38h /5qg== X-Gm-Message-State: AOAM532HCYcmQI0A876T+uTQh98UvI4mVZVv+I+FC7PXcKF+4aQNX6MF TaLgdh/H1oMxo6EP0j84dWRVE6mm3DY+H/e87M0= X-Received: by 2002:a05:651c:1051:b0:247:ea0d:a57c with SMTP id x17-20020a05651c105100b00247ea0da57cmr14118926ljm.204.1647278947501; Mon, 14 Mar 2022 10:29:07 -0700 (PDT) MIME-Version: 1.0 References: <20220310082202.1229345-1-namhyung@kernel.org> <20220310082202.1229345-2-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Mon, 14 Mar 2022 10:28:56 -0700 Message-ID: Subject: Re: [PATCH 2/2] bpf/selftests: Test skipping stacktrace To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Networking , bpf , LKML , Arnaldo Carvalho de Melo , Peter Zijlstra , Eugene Loh , Hao Luo Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, Mar 11, 2022 at 2:23 PM Andrii Nakryiko wrote: > > On Thu, Mar 10, 2022 at 12:22 AM Namhyung Kim wrote: > > +SEC("tracepoint/sched/sched_switch") > > +int oncpu(struct sched_switch_args *ctx) > > +{ > > + __u32 max_len = TEST_STACK_DEPTH * sizeof(__u64); > > + __u32 key = 0, val = 0, *value_p; > > + __u64 *stack_p; > > + > > please also add filtering by PID to avoid interference from other > selftests when run in parallel mode Will do! Thanks, Namhyung > > > + value_p = bpf_map_lookup_elem(&control_map, &key); > > + if (value_p && *value_p) > > + return 0; /* skip if non-zero *value_p */ > > + > > + /* it should allow skipping whole buffer size entries */ > > + key = bpf_get_stackid(ctx, &stackmap, TEST_STACK_DEPTH); > > + if ((int)key >= 0) { > > + /* The size of stackmap and stack_amap should be the same */ > > + bpf_map_update_elem(&stackid_hmap, &key, &val, 0); > > + stack_p = bpf_map_lookup_elem(&stack_amap, &key); > > + if (stack_p) { > > + bpf_get_stack(ctx, stack_p, max_len, TEST_STACK_DEPTH); > > + /* it wrongly skipped all the entries and filled zero */ > > + if (stack_p[0] == 0) > > + failed = 1; > > + } > > + } else if ((int)key == -14/*EFAULT*/) { > > + /* old kernel doesn't support skipping that many entries */ > > + failed = 2; > > + } > > + > > + return 0; > > +} > > + > > +char _license[] SEC("license") = "GPL"; > > -- > > 2.35.1.723.g4982287a31-goog > >