Received: by 10.192.165.156 with SMTP id m28csp284945imm; Wed, 18 Apr 2018 22:14:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/faFrSNclZgcLkl7Q8bqBjkuQcswUeKPf2JApKn699oTg7zzd/iV409wYl4H+f3qKOPvRm X-Received: by 2002:a17:902:24c7:: with SMTP id l7-v6mr4854444plg.320.1524114861751; Wed, 18 Apr 2018 22:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524114861; cv=none; d=google.com; s=arc-20160816; b=qrfqJGhWWyr9Z8n7oMGdOcgPyocOVM5sfHpqf1HMJxf6hJTig3keg1zRgVpe0xtuND 1tJvo/+qM6FPzvRRXz5W/SrGja5pxTy5aofqjnQBXxuZ8w7ldQoYLh+GtrF3nSrDNAwn ZCJci/+t2XmT9cy3rYqftbR4vZJT31uJapAisyuVs4SWH7ieB9slsotMUI1dnMSx5hXX qGI+VFZeYl7iQYSSo+mJxyZLN3IYtk8ofDMJtnpG9ccZXwWLaMEHT3N9guR08/G/g1st Kz4n3VKkDLRlUZX4RnQSfHF9HuRaDrfN4YPe7XNoIz4eRx5iZEExKnkxYiAxxQej5VoP qXSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=J5599mY/U5gKi85ysHlvAWffrd6mI5vWLm5ix/7Z1P8=; b=nrZQOf96i6s28182IAHr6RJhocr0JjzcWzGv7fGeJoOXScKIeApBXW9gJ6yQEmsg/c EM0DUpZsQ6+hnoifyoe0es5R5twfCgRDdWMXIbTlpPP9Eu5BPfWqWGw9/s4ZedCBxLwz jpI++xoW6QVkcxefxp+ZduWmiSp56O9B1aLqVwM0vcQ5YjjgXA64N7uz+TbhV2/eMNiT 3h01iXckwIPPrqdkETAQ0PvePp5H2zlpPK1iUzX2CxrcSmoJioZ44lrjv5vj9jPLukjb F7PAK6l+vEICHBHll+dh1EjY4q9KIbSh8zJG06tBvtT7rCvXvg06iVFa79k6GsNVy2vl ARNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eEOgrhms; 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 b1-v6si2737461plc.403.2018.04.18.22.14.07; Wed, 18 Apr 2018 22:14:21 -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=eEOgrhms; 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 S1753266AbeDSFNA (ORCPT + 99 others); Thu, 19 Apr 2018 01:13:00 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38307 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752325AbeDSFM6 (ORCPT ); Thu, 19 Apr 2018 01:12:58 -0400 Received: by mail-pf0-f193.google.com with SMTP id y69so2044501pfb.5 for ; Wed, 18 Apr 2018 22:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=J5599mY/U5gKi85ysHlvAWffrd6mI5vWLm5ix/7Z1P8=; b=eEOgrhmsYbl6wUoWohWIyiGmxQsxweu73G63hjuMEZjPs6PDR5MyoWzv6teNZbVZkR 4kVY0p2ScN8XXTZNhg3gX5EynBZsTxSLfVSMvOU3j2r5iEgZDep7DkDKehuELhdZxfDq J7qz8KMOdnZIUqWYPH9HD+01DO7nicWjgjmYU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=J5599mY/U5gKi85ysHlvAWffrd6mI5vWLm5ix/7Z1P8=; b=R7cTK8rdL0TuIFiY6AlcgE33FxW+1MA9xtVRaUhuyG/sHfLTfFWfugJILvDmtQ1dvB VPXdYEammQphybzkxCu0fMzwPQHB2sa8khbZmOieVo45twtEgKFXjwNm6hGoYE6M3nZS Zl2OGF3H4KmDmhoriQRreGorXgOUIg1YYYWs/D0lkaMMxeS4iAIQmS+XOdEKMXNcBEkv 3i87pXX09NKNTvN+2otjKOYZmt07ONNzSCRuIZWCbZIOMw7+Bbv09EPmlwrye01ogJM6 AzGxsCAaFDVpSNRsMnLSupAEAloSlZFA9hQvEry162Sp2qY0sTrRWPBCwFC98GP+iNUX BYHQ== X-Gm-Message-State: ALQs6tBpn8URvd0ugF1PP1MC63tCQ5v1jsK2eOJ62Jpz0Mk7WvkoSAjo yMLIqu0fUmG3BYmFmeqZTGWwsRGc5ltV+Q== X-Received: by 10.98.180.2 with SMTP id h2mr4470638pfn.189.1524114777448; Wed, 18 Apr 2018 22:12:57 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([45.77.181.154]) by smtp.gmail.com with ESMTPSA id k14sm5569409pfb.139.2018.04.18.22.12.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 22:12:55 -0700 (PDT) Date: Thu, 19 Apr 2018 13:12:49 +0800 From: Leo Yan To: Alexei Starovoitov Cc: Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next 4/5] samples/bpf: Refine printing symbol for sampleip Message-ID: <20180419051249.GA27295@leoy-ThinkPad-X240s> References: <1524101646-6544-1-git-send-email-leo.yan@linaro.org> <1524101646-6544-5-git-send-email-leo.yan@linaro.org> <20180419044743.srjhqegvir5exub5@ast-mbp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180419044743.srjhqegvir5exub5@ast-mbp> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 18, 2018 at 09:47:45PM -0700, Alexei Starovoitov wrote: > On Thu, Apr 19, 2018 at 09:34:05AM +0800, Leo Yan wrote: > > 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(-) > > > > 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); > > yes. it is x64 specific, since it's a sample code, > but simply removing it is not a fix. > It makes this sampleip code behaving incorrectly. > To do such 'cleanup of ksym' please refactor it in the true generic way, > so these ksym* helpers can work on all archs and put this new > functionality into selftests. Just want to check, are you suggesting to create a standalone testing for kallsyms (like a folder tools/testing/selftests/ksym) or do you mean to place the generic code into folder tools/testing/selftests/bpf/? > If you can convert these examples into proper self-checking tests > that run out of selftests that would be awesome. Thank you for suggestions, Alexei. > Thanks! >