Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030283AbVLNDLH (ORCPT ); Tue, 13 Dec 2005 22:11:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030312AbVLNDLH (ORCPT ); Tue, 13 Dec 2005 22:11:07 -0500 Received: from fmr20.intel.com ([134.134.136.19]:37014 "EHLO orsfmr005.jf.intel.com") by vger.kernel.org with ESMTP id S1030283AbVLNDLF (ORCPT ); Tue, 13 Dec 2005 22:11:05 -0500 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C6005C.03E147A9" Subject: [PATCH] Export cpu topology for IA32 and x86_64 by sysfs X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Wed, 14 Dec 2005 11:11:00 +0800 Message-ID: <8126E4F969BA254AB43EA03C59F44E840431BB03@pdsmsx404> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: [PATCH] Export cpu topology for IA32 and x86_64 by sysfs Thread-Index: AcYAXAIadSeYnIAMR8m+XlfBq0ckUA== From: "Zhang, Yanmin" To: , Cc: "Pallipadi, Venkatesh" X-OriginalArrivalTime: 14 Dec 2005 03:11:03.0341 (UTC) FILETIME=[0428C5D0:01C6005C] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6189 Lines: 101 This is a multi-part message in MIME format. ------_=_NextPart_001_01C6005C.03E147A9 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable The patch exports the cpu topology info through sysfs on ia32/x86_64 machines. The info is similar to /proc/cpuinfo. The exported items are: /sys/devices/system/cpu/cpuX/topology/physical_package_id(representing the physical package id of cpu X) /sys/devices/system/cpu/cpuX/topology/core_id (representing the cpu core id to cpu X) /sys/devices/system/cpu/cpuX/topology/thread_siblings (representing the thread siblings to cpu X) /sys/devices/system/cpu/cpuX/topology/core_siblings (represeting the core siblings to cpu X) Signed-off-by: Zhang Yanmin ------_=_NextPart_001_01C6005C.03E147A9 Content-Type: application/octet-stream; name="cpu_topology_2.6.14_mm1_ia32_x86_64.v6.patch" Content-Transfer-Encoding: base64 Content-Description: cpu_topology_2.6.14_mm1_ia32_x86_64.v6.patch Content-Disposition: attachment; filename="cpu_topology_2.6.14_mm1_ia32_x86_64.v6.patch" LS0tIGxpbnV4LTIuNi4xNF9tbTEvYXJjaC9pMzg2L21hY2gtZGVmYXVsdC90b3BvbG9neS5jCTIw MDUtMTEtMDkgMDI6NTU6MjEuMDAwMDAwMDAwICswODAwCisrKyBsaW51eC0yLjYuMTRfbW0xX2Zp eC9hcmNoL2kzODYvbWFjaC1kZWZhdWx0L3RvcG9sb2d5LmMJMjAwNS0xMS0wOSAwMzoxNTozMy4w MDAwMDAwMDAgKzA4MDAKQEAgLTk1LDMgKzk1LDE0MSBAQCBzdGF0aWMgaW50IF9faW5pdCB0b3Bv bG9neV9pbml0KHZvaWQpCiAjZW5kaWYgLyogQ09ORklHX05VTUEgKi8KIAogc3Vic3lzX2luaXRj YWxsKHRvcG9sb2d5X2luaXQpOworCisKKyNpZiBkZWZpbmVkKENPTkZJR19TWVNGUykgJiYgZGVm aW5lZChDT05GSUdfU01QKQorCisvKgorICogRXhwb3J0IGNwdSB0b3BvbG9neSB0aHJvdWdoIHN5 c2ZzCisgKi8KKworLyogcG9pbnRlciB0byBrb2JqZWN0IGZvciBjcHVYL3RvcG9sb2d5ICovCitz dGF0aWMgc3RydWN0IGtvYmplY3QgKiBjcHVfdG9wb2xvZ3lfa29iamVjdDsKKworI2RlZmluZSBk ZWZpbmVfb25lX3JvKF9uYW1lKSBcCitzdGF0aWMgc3RydWN0IGF0dHJpYnV0ZSBfbmFtZSA9IFwK Kwl7Lm5hbWUgPSBfX3N0cmluZ2lmeShfbmFtZSksIC5tb2RlID0gMDQ0NCwgLm93bmVyID0gVEhJ U19NT0RVTEV9CisKK2RlZmluZV9vbmVfcm8ocGh5c2ljYWxfcGFja2FnZV9p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WQp Cit7CisJaW50IGk7CisKKwljcHVfdG9wb2xvZ3lfa29iamVjdCA9IGttYWxsb2Moc2l6ZW9mKHN0 cnVjdCBrb2JqZWN0KSAqIE5SX0NQVVMsCisJCQlHRlBfS0VSTkVMKTsKKwlpZiAoIWNwdV90b3Bv bG9neV9rb2JqZWN0KQorCQlyZXR1cm4gLUVOT01FTTsKKworCWZvcl9lYWNoX29ubGluZV9jcHUo aSkgeworCQl0b3BvbG9neV9jcHVfY2FsbGJhY2soJnRvcG9sb2d5X2NwdV9ub3RpZmllciwgQ1BV X09OTElORSwKKwkJCQkodm9pZCAqKShsb25nKWkpOworCX0KKworCXJlZ2lzdGVyX2NwdV9ub3Rp ZmllcigmdG9wb2xvZ3lfY3B1X25vdGlmaWVyKTsKKworCXJldHVybiAwOworfQorCitkZXZpY2Vf aW5pdGNhbGwodG9wb2xvZ3lfc3lzZnNfaW5pdCk7CisKKyNlbmRpZgkvL2RlZmluZWQoQ09ORklH X1NZU0ZTKSAmJiBkZWZpbmVkKENPTkZJR19TTVApCisK ------_=_NextPart_001_01C6005C.03E147A9-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/