Received: by 10.192.165.156 with SMTP id m28csp291070imm; Wed, 18 Apr 2018 22:22:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+hJ++SG16J32sgFW/8Krwng9mYJuYV9ZR9K7NHu8ZwVRmqv7TEHRemPcJWKjng3WfDbVJH X-Received: by 10.99.126.71 with SMTP id o7mr3925140pgn.366.1524115369052; Wed, 18 Apr 2018 22:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524115369; cv=none; d=google.com; s=arc-20160816; b=VHhyf1TyrY6BFOCymNOPVVwGwJL9ylNYvV0G+NEpGpkVp9e5kNrI5YfJoxX32wTZYI kcdU04MbE6kaMMftYnDKRFi5KNyZHIq8A+XnkCMk6ZfplGX1zpFDzn8EmkCBEMqhNRkB 65fsg/eMf+ct85FUdWUIa40Aue7cXLYDtSwOIGdwMa13/5sRoz0SKdBjvW5tSNtTWsU5 tJ6Q/7D6VhPqL+i28s7VQ4BKip6ohFHneQYyoFQ9LmPtRKg2PEkPFtwSrRWCcAUQIaZh u9VmZgH6N98YNy7IuluLcASEOqn1UdPBPNHrbA26lnh9TmPxUB1+ZhwhybaaZ1DsYB7X 5YUQ== 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=ig/KL6wyzCvpGw9PQx8PrlEiJQy16BSXYUsCb/gP7Gc=; b=hQpv0KKLBo6cAkY3BKmJeOJogvSdSogCPyQhizaA0YiSt7NqufXkG5TQW7f1QoWjoD ojzNkeLguxtsE9z9E3kayUhd+PWVYBVplfPAEsRiUNwU/5ONbdtnno+qQegH5gFN/kL3 O06X03EiOdkygdVHd3xVQ5g+1EprJ3VcenCAaL/MKfwW/6OysKonO4v4fljBNqQKTK9c rw7S0QGorVfgdHCXWprXmiZVPOx8vPZX4aTJ0XgLPPRLuK5Vyk+H7Pa1HHzx6zR6UT/d pdEM7InklpcdP6nUxmL96cG2xR5wjyKtpijT5sTS4f0RXWOJT9bYdlhDzLAqCEvPrTCy 1+Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rMYbO4S7; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 94-v6si2690652plb.475.2018.04.18.22.22.34; Wed, 18 Apr 2018 22:22:49 -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=@gmail.com header.s=20161025 header.b=rMYbO4S7; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753249AbeDSFVa (ORCPT + 99 others); Thu, 19 Apr 2018 01:21:30 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:42553 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750913AbeDSFV3 (ORCPT ); Thu, 19 Apr 2018 01:21:29 -0400 Received: by mail-pf0-f196.google.com with SMTP id o16so2047571pfk.9; Wed, 18 Apr 2018 22:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ig/KL6wyzCvpGw9PQx8PrlEiJQy16BSXYUsCb/gP7Gc=; b=rMYbO4S7Mv1DGNicIGxFn2A+XjuAsK/yAVo6i8ikWhA8pzFPLwp4Evwxk+XwJPWVur NmVr+7E9fYT4YT8NyQKqFwdOiD655vLp9qkmjvklV6DVHoVf6wgOJdjx6GY5f66/XUbI ad2bziIAVfukBoHxnL2pOuWBbCZu54hDO+XivSpTtKkDi810/VKgvpn3gjF2amuSE2Nb H9oOVDo1a2/N7MJppFgPIR1crJWYTFV/KSxE9nH8SupE4mVBcs8JQ9e/Qt++PcGbcCJL NnlFbSg9c9oZFKglhXCmnp6YuFac2M+Pgmazfmool+ZkIBFS8S3s3z4iW+YMya/K74bO I1Mg== 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=ig/KL6wyzCvpGw9PQx8PrlEiJQy16BSXYUsCb/gP7Gc=; b=eiqXJXBFgKjtPIBOOzsY2x9sv0Wb487Gd0CKr+JtuJ6oaVgWTe6xcoqtHsZ5wQ+VeR rZGCaxsE/zj+12Hysgap4IrpFltjWpRCjXVbmmVyzl9rgyuHRqaL1JEDGYG2TakP3Zt9 W6rOSwK8BZBTA1gdC2Xj1tVexkRgXw8+Et+ZX7nBbovx6H+hCo1vvl2fGNR4xjQ+lF/q 2k0Cg6J5g+u2+U+9MXhK9NryGZN4YOaAEyUIeRoIrSVg4d5m41pcvLc2/Dy4mfA8XGav 1rmIJ6GIWElSDaOO/DLtNTpcE/1G5Lu6rV8Wd6Ft8fnW7XKxqcbODRodznFFdB6BvOVd 2/gg== X-Gm-Message-State: ALQs6tBrkXObxywHkrWW2r6MBITQxZlN65wIjAePQR0lj5NqPhE3CHF4 DjcmDIXqm74dKUxSokB5fi0= X-Received: by 10.98.64.91 with SMTP id n88mr4530267pfa.229.1524115288362; Wed, 18 Apr 2018 22:21:28 -0700 (PDT) Received: from ast-mbp ([2620:10d:c090:180::1:6dbb]) by smtp.gmail.com with ESMTPSA id x29sm5698573pfk.68.2018.04.18.22.21.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 22:21:27 -0700 (PDT) Date: Wed, 18 Apr 2018 22:21:25 -0700 From: Alexei Starovoitov To: Leo Yan 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: <20180419052124.xzaz66vehd6pofnh@ast-mbp> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180419051249.GA27295@leoy-ThinkPad-X240s> User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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!