Received: by 10.192.165.156 with SMTP id m28csp300419imm; Wed, 18 Apr 2018 22:35:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+hTVxAvQ8ZW9XIGkpTe4bNRpY/bQd+CdaIZa5/QX1bTimR5mkJU8Gmc+NjilXFyXmN+oQT X-Received: by 10.101.76.129 with SMTP id m1mr3955655pgt.90.1524116116239; Wed, 18 Apr 2018 22:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524116116; cv=none; d=google.com; s=arc-20160816; b=Frb/5LEgfsUa87aJSb6FGf9hdOkGxfWf2lCxo2nul7rfI9LvIdLgL77IigZeAASax5 oMD49s0xM8T/du8g/VzfW4Q/oC/vmLgaUqjP9bybQ4nGflqDSFKO3Kx3kXf0GaPXMdiM MiSXr/bnmXTQc/CKPvanfRG3Hr/8TMcV7XQNArbNFMtbBaBIMWCsr+EZ5bAzOPf9b4Jk eidhe89acrKidntGT6hzuhxVx7M6WLQmfh+cGi2co5ftq2tKNHYhLJNJg8m7saHApepx UmLMjUqJV1VHI2snqkH0WEjgXH34uRC7tGkGYbE94tmiIv5uo0h90TVdPjOTfhDHRR42 XuuA== 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=TO5cIHI03yjaeKk8YOlLCPf534OXyGZ0isA3TB12zuE=; b=DJZWWcLGQyS+Nt1+6faip++HTzxW0q0WRmdafql/hVimEOhPlSCNWKIVGyn2e1UZpW OSRsY+4nDB6bGHcooajXV0lHHjii/aEFGymdOvdqBlQtCX8MEPuqjBcnAhHIdcOWk8DP SjjpMK3DJhC7JE7g5iKfgdYFAomf2OfHUq4jWLbVS/QJPJPeRPsi5Dr429IwU8VMo03Y 1WkXtr6F6H3qjYIt3ivEjye7jjw1JVpC8AXsBdFJuk1Vtjnwns8T0jSLLnaUGU9YAwJm iONLolY6JmcV9+IqrLb9Oz4cCINJTeXv1RhvDbz0RmrS4bNMT3okXemfXmE4Ia9qTgxk hAwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kHz6X19P; 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 h80si2617173pfj.129.2018.04.18.22.35.02; Wed, 18 Apr 2018 22:35:16 -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=kHz6X19P; 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 S1753328AbeDSFdp (ORCPT + 99 others); Thu, 19 Apr 2018 01:33:45 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:43922 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753208AbeDSFdn (ORCPT ); Thu, 19 Apr 2018 01:33:43 -0400 Received: by mail-pf0-f196.google.com with SMTP id j11so2058805pff.10 for ; Wed, 18 Apr 2018 22:33:43 -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=TO5cIHI03yjaeKk8YOlLCPf534OXyGZ0isA3TB12zuE=; b=kHz6X19PeBX+Ml5uCQedmQFCxaQrK150B7sLAx+8VSL7Fd1S3TleGGq6xt4KCCHqM7 ZaP0xxEq03BCGv5E2ZN4kL1xwx5yForV38MAMlq8CARWMITpp+b+r4i/IU8o1pDPnvN1 xDG5vpzAMFC286NYpwatGfwFfYCOsSLqE3PzQ= 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=TO5cIHI03yjaeKk8YOlLCPf534OXyGZ0isA3TB12zuE=; b=Xq7lmBUoiylGA0K4zAY1J2tc6+nrO2d8h6edjY/pF/PrBXpJclikMBhagCLqIh2nfr EoD0RfY3OkqLCQJiNvL+qkx5LZXO4Lzvxorwy6A0jbJIXw5faFt4EXrCqNoFmks9FSyG ouQ70SVa9A4IKO3taz2wfXk91dZGvz3BIDYTECREUZFENZKFpDO9rcCge7DJ7pLP78jG Ji9L/T8yGtChzOpq+DczygpqAPT9gCSN+lQPw/hm2LP5Lj3LqmW7yzjdQIfBVh5CKtsz 2dIvooM45YUbV3Q9WNQ+she2wpEHNm0vQNzzQEJqNN9hkeKKVNnZvRebRGOzKrZ6vbp3 mDTQ== X-Gm-Message-State: ALQs6tAS9xEda+GpXPXv+pelEEeYTAe0B6/knyIjeFuvGMlKV2LcIqT+ urZUz33dTo3p+pqBfr4UYzw453HRWQhyOQ== X-Received: by 10.99.51.137 with SMTP id z131mr4014644pgz.386.1524116023370; Wed, 18 Apr 2018 22:33:43 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([45.77.181.154]) by smtp.gmail.com with ESMTPSA id 86sm6669933pfh.93.2018.04.18.22.33.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 22:33:42 -0700 (PDT) Date: Thu, 19 Apr 2018 13:33:35 +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: <20180419053335.GB27295@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> <20180419051249.GA27295@leoy-ThinkPad-X240s> <20180419052124.xzaz66vehd6pofnh@ast-mbp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180419052124.xzaz66vehd6pofnh@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 10:21:25PM -0700, Alexei Starovoitov wrote: > On Thu, Apr 19, 2018 at 01:12:49PM +0800, Leo Yan wrote: > > 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/? > > I think the minimal first step is to cleanup ksym bits into something > that bpf selftests can use and keep it as new .c in > tools/testing/selftests/bpf/ > Later if it becomes useful for other tests in selftests it can be moved. Thanks for explanation, now it's clear for me :) > Thanks! >