From patchwork Thu Apr 19 01:34:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 133678 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp88153ljf; Wed, 18 Apr 2018 18:34:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx48h5ccg7jcugbnNCYUtNCeWdi1b4/wlp4H9xzVwC0131+ETUQcXiCnEUW9A6ynRoSmA7DCe X-Received: by 2002:a17:902:7004:: with SMTP id y4-v6mr4278382plk.3.1524101684401; Wed, 18 Apr 2018 18:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524101684; cv=none; d=google.com; s=arc-20160816; b=P/v7EgaNzjjmkf/kl9MYK2V615vmI1jmUhDGynX4exwnpJj/UTryAxthBi2Svco0dL N1shvbV2vOAqUh/gLwN3OHSwY56RvTNk7pS4O3K2Q0yfBNaWnzkDfFNH7ewggJ5M0yjS /mKObK7MxACgucyjfRuHvG1MOgvbPB0lIFMp+kdwnDeBR8AwRsz/lNTCQyHxNcmx9Tm0 IvmLW9t8Xtz9DYBP3v04WmW1IXbFvK3/SCtfRSLbo0rzisecwZQw9psOSkXPGbMmrx6j j+Hgesma9ENXRLmyAunvfm//zQEeb2yMH7rN30bwLXi4RoYHCT79lN8XWzR6G/q0dNei jVVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Q9j3hjp6C3hGgRQ1gOH+nbpkRqMgT/dlUC6fOr13IQA=; b=DGoEwGdXRY1Lgo7OFqju5mldooY7K4SnMMdZasu+11lUVSIVskrJWdaNTh+dFUOy8v zI4UH6KTG3X0WI9aapvJkq8weAn8ar3+PSDnc6Z2L/sZV3aQRaNGCDGhr2Gqv2784q9c 9ZMCdtE66nrGL74P0l9rM7M2BrckThkIzPdI0Wkfly3wgWzPdsdUT5R0fA7csNaaeY6p yy6aMZNGmRLM0TlHC71z8Tu2v2egYe7TmDJuVD+r4a0L9KZoFmWJbvB97YrodrX/e8MD cVsUthvXiAfRlclOeysNecuSgmrJZtQKifAaUgMD72Yz31QjPcBBx9zGHrSHpPPuuQwf pjHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AXd1J2hI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4-v6si2401335pln.468.2018.04.18.18.34.44; Wed, 18 Apr 2018 18:34:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AXd1J2hI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753303AbeDSBek (ORCPT + 29 others); Wed, 18 Apr 2018 21:34:40 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:40496 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752899AbeDSBeh (ORCPT ); Wed, 18 Apr 2018 21:34:37 -0400 Received: by mail-ot0-f193.google.com with SMTP id h8-v6so4113337otj.7 for ; Wed, 18 Apr 2018 18:34:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q9j3hjp6C3hGgRQ1gOH+nbpkRqMgT/dlUC6fOr13IQA=; b=AXd1J2hIbd9dufSqCb5RReQEY8KXYcIev6xjCda8rkHKoqqV16bIhCg/H5MHe5LoP1 2/Xi3ShG93O2R598Ib2kt9kjmo0kGj45pj6Hb9DfCx9gjWmmS98gE6R09WdzoE5R2V2a hNLAwEOGngSEs1Z2IlXMsAoCpod4dTGoIx/pU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q9j3hjp6C3hGgRQ1gOH+nbpkRqMgT/dlUC6fOr13IQA=; b=DW0ks7Fs0BGgGJ7oK9A+DN55IKcOdaDil/1fXJjFsE0/AfMb5AeAmEivPiHrqMo3cu qQWOy2qzfYZMeUFUNJe+nUr2m0HZLQJeoUI7xSKAcgRXA9dPAZyvhomk3ixSsmELBpNf 0U6QM/Vbz+irNoO6dWyIZmVGZlOLbF+clYtH5Wc1p5rzyIThz/a3Msg1ylDkFMLhfW4O TCTz36fIlRolDelOogwbjby8BSalGYyC2PIdeHJc33BxlIAPt3ooHt4EwgbLzB2E8BAc JXXmozvKNQUqRMxBsCetLrjEVpJzqD3yZNKnXfcvLy3EeHBk0w6uL/S4pL8rj4uszTkS Dcrg== X-Gm-Message-State: ALQs6tDAxUqiKtSIO4YO69wqoL9RCUCh9dT6ObeMw/LLQuKdY+WbNJSl m9C+KPHvQc+2E5J0QHUxpMYAuA== X-Received: by 2002:a9d:2222:: with SMTP id o31-v6mr2992588ota.340.1524101676677; Wed, 18 Apr 2018 18:34:36 -0700 (PDT) Received: from localhost.localdomain (li973-238.members.linode.com. [45.33.19.238]) by smtp.gmail.com with ESMTPSA id m84-v6sm1389662oia.1.2018.04.18.18.34.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Apr 2018 18:34:35 -0700 (PDT) From: Leo Yan To: Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH bpf-next 4/5] samples/bpf: Refine printing symbol for sampleip Date: Thu, 19 Apr 2018 09:34:05 +0800 Message-Id: <1524101646-6544-5-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524101646-6544-1-git-send-email-leo.yan@linaro.org> References: <1524101646-6544-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The code defines macro 'PAGE_OFFSET' and uses it to decide if the address is in kernel space or not. But different architecture has different 'PAGE_OFFSET' so this program cannot be used for all platforms. This commit changes to check returned pointer from ksym_search() to judge if the address falls into kernel space or not, and removes macro 'PAGE_OFFSET' as it isn't used anymore. As result, this program has no architecture dependency. Signed-off-by: Leo Yan --- samples/bpf/sampleip_user.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 1.9.1 diff --git a/samples/bpf/sampleip_user.c b/samples/bpf/sampleip_user.c index 4ed690b..0eea1b3 100644 --- a/samples/bpf/sampleip_user.c +++ b/samples/bpf/sampleip_user.c @@ -26,7 +26,6 @@ #define DEFAULT_FREQ 99 #define DEFAULT_SECS 5 #define MAX_IPS 8192 -#define PAGE_OFFSET 0xffff880000000000 static int nr_cpus; @@ -107,14 +106,13 @@ static void print_ip_map(int fd) /* sort and print */ qsort(counts, max, sizeof(struct ipcount), count_cmp); for (i = 0; i < max; i++) { - if (counts[i].ip > PAGE_OFFSET) { - sym = ksym_search(counts[i].ip); + sym = ksym_search(counts[i].ip); + if (sym) printf("0x%-17llx %-32s %u\n", counts[i].ip, sym->name, counts[i].count); - } else { + else printf("0x%-17llx %-32s %u\n", counts[i].ip, "(user)", counts[i].count); - } } if (max == MAX_IPS) {