From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by dpdk.org (Postfix) with ESMTP id 411931F3 for ; Wed, 7 Aug 2013 17:52:20 +0200 (CEST) Received: by mail-pd0-f170.google.com with SMTP id x10so1537660pdj.29 for ; Wed, 07 Aug 2013 08:52:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=UtJVIv5qTflYTtWukEHWxyKTqeZnfq5JaBnWmsh6w5w=; b=X5/l21LUNpwO87MHxqFOmvtKE94uFxz2WCXpeeHvD0sATGK+nOOhayCgVAUkelIA2k qMF7pdjNMeJ9Hq5UqIiaI5eF3gqdEnFmgE+Ge8ohZrWBw6mSS3w/HDo6iSQxdvKeduDt hlvDeNAk8tnXTaSpIMqWcLKR8qgk5yfwvmIGKZFShWv2nrK+8U5SeEG0qHeG1MAMg44/ rWAtI23W0ZvSKJSNu3r3nL8VgmnkUBh5ery+l0sI7O1osPQt+MPeG8Y3lGtr3aO4ad0u eVSrFSkBCdkbGdVOvjpefJLKfustFYK277P/VauQHI8yTT2x1VULCByp/QmHyhT6U6na qTUw== X-Gm-Message-State: ALoCoQkYQ/64/RodEdFoYRKmcuuksUME0vA0IOW2s6enQnhKkoU/5CNQaTllDp7odgk4Wuptmxfb X-Received: by 10.66.171.204 with SMTP id aw12mr1440152pac.7.1375890766349; Wed, 07 Aug 2013 08:52:46 -0700 (PDT) Received: from nehalam.linuxnetplumber.net (static-50-53-69-237.bvtn.or.frontiernet.net. [50.53.69.237]) by mx.google.com with ESMTPSA id ib9sm8913479pbc.43.2013.08.07.08.52.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 07 Aug 2013 08:52:45 -0700 (PDT) Date: Wed, 7 Aug 2013 08:52:41 -0700 From: Stephen Hemminger To: dvr Message-ID: <20130807085241.684ed79a@nehalam.linuxnetplumber.net> In-Reply-To: <77584a69.d001.1405769661d.Coremail.jinxiu.1006@163.com> References: <77584a69.d001.1405769661d.Coremail.jinxiu.1006@163.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] Get the socket id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2013 15:52:20 -0000 On Wed, 7 Aug 2013 14:14:19 +0800 (CST) dvr wrote: > hi, > all > I'm confused with the following code(Eal_memory.c in lib\librte_eal\linuxapp\eal directory, LINE 373): > > nodestr = strstr(buf," N"); > if(nodestr == NULL) {...} > nodestr += 2; > end = strstr(nodestr,"="); > if(end == NULL) {...} > // here nodestr = "0=1" > end[0] = '\0'; > end = NULL; > // here nodestr = "0" > socket_id = strtoul(nodestr,&end,0); > > Through "printf", I know that: > buf = "00200000 default file=/mnt/dpdk/huge/rtemap_1 huge dirty=1 N0=1" > And finally socket_id=0 > My question is :why we get the socket_id before "=" instead of after "=" ? > and if we want to get the character after "N", isn't this code too complex? > > I will be very appreciate for any help. > Regards! > > Maria > Good question. The best reference for the kernel proc files is usually in the Linux kernel source Documentation directory. But can't find any documentation on numa_maps in detail. Inside kernel VM, there is an array of numa_maps for each process. The two parts of NX=Y are: X => the numa map index Y => the numa node associated with that map Therefore it is possible to have multiple entries, like: "00200000 default file=/myfile dirty=1 N0=1 N1=2" if the the memory region crosses multiple NUMA nodes. Since huge pages are pinned to numa node, you won't see that for them. Basically if "huge" is in the line only one NX=Y entry will be present; and the X part is unimportant.