Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030423AbVLNDad (ORCPT ); Tue, 13 Dec 2005 22:30:33 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030424AbVLNDad (ORCPT ); Tue, 13 Dec 2005 22:30:33 -0500 Received: from fmr18.intel.com ([134.134.136.17]:42384 "EHLO orsfmr003.jf.intel.com") by vger.kernel.org with ESMTP id S1030423AbVLNDad (ORCPT ); Tue, 13 Dec 2005 22:30:33 -0500 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C6005E.BBCEE0A4" Subject: [PATCH 1/2] Export cpu info by sysfs X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Wed, 14 Dec 2005 11:30:28 +0800 Message-ID: <8126E4F969BA254AB43EA03C59F44E840431BB3B@pdsmsx404> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: [PATCH 1/2] Export cpu info by sysfs Thread-Index: AcYAXroSFGPH5J/DRM2wWNmVxPsLfQ== From: "Zhang, Yanmin" To: Cc: "Pallipadi, Venkatesh" X-OriginalArrivalTime: 14 Dec 2005 03:30:31.0024 (UTC) FILETIME=[BC270F00:01C6005E] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6706 Lines: 109 This is a multi-part message in MIME format. ------_=_NextPart_001_01C6005E.BBCEE0A4 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable I worked out 2 patches to export cpu topology and cache info by sysfs. The first patch is to export cpu topology info including below items (attributes) which are similar to /proc/cpuinfo. /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_id (representing the cpu thread 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_01C6005E.BBCEE0A4 Content-Type: application/octet-stream; name="export_topology_2.6.14_mm1_ia64.v5.patch" Content-Transfer-Encoding: base64 Content-Description: export_topology_2.6.14_mm1_ia64.v5.patch Content-Disposition: attachment; filename="export_topology_2.6.14_mm1_ia64.v5.patch" ZGlmZiAtTnJhdXAgbGludXgtMi42LjE0X21tMS9hcmNoL2lhNjQva2VybmVsL3RvcG9sb2d5LmMg bGludXgtMi42LjE0X21tMV90b3BvbG9neS9hcmNoL2lhNjQva2VybmVsL3RvcG9sb2d5LmMKLS0t IGxpbnV4LTIuNi4xNF9tbTEvYXJjaC9pYTY0L2tlcm5lbC90b3BvbG9neS5jCTIwMDUtMTEtMDcg MDI6MzQ6MDYuMDAwMDAwMDAwICswODAwCisrKyBsaW51eC0yLjYuMTRfbW0xX3RvcG9sb2d5L2Fy Y2gvaWE2NC9rZXJuZWwvdG9wb2xvZ3kuYwkyMDA1LTEyLTEzIDE4OjI1OjA4LjAwMDAwMDAwMCAr MDgwMApAQCAtOTgsNCArOTgsMTUxIEBAIG91dDoKIAlyZXR1cm4gZXJyOwogfQogCi1fX2luaXRj YWxsKHRvcG9sb2d5X2luaXQpOworc3Vic3lzX2luaXRjYWxsKHRvcG9sb2d5X2luaXQpOworCisK KyNpZiBkZWZpbmVkKENPTkZJR19TWVNGUykKKworI2lmIGRlZmluZWQoQ09ORklHX1NNUCkKKwor LyoKKyAqIEV4cG9ydCBjcHUgdG9wb2xvZ3kgdGhyb3VnaCBzeXNmcworICovCisKKy8qIHBvaW50 ZXIgdG8ga29iamVjdCBmb3IgY3B1WC90b3BvbG9neSAqLworc3RhdGljIHN0cnVjdCBrb2JqZWN0 ICogY3B1X3RvcG9sb2d5X2tvYmplY3Q7CisKKyNkZWZpbmUgZGVmaW5lX29uZV9ybyhfbmFtZSkg XAorc3RhdGljIHN0cnVjdCBhdHRyaWJ1dGUgX25h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xvZ3lfYWRkX2Rldihz eXNfZGV2KTsKKwkJCWJyZWFrOworI2lmZGVmCUNPTkZJR19IT1RQTFVHX0NQVQorCQljYXNlIENQ VV9ERUFEOgorCQkJdG9wb2xvZ3lfcmVtb3ZlX2RldihzeXNfZGV2KTsKKwkJCWJyZWFrOworI2Vu ZGlmCisJfQorCXJldHVybiBOT1RJRllfT0s7Cit9CisKK3N0YXRpYyBzdHJ1Y3Qgbm90aWZpZXJf YmxvY2sgdG9wb2xvZ3lfY3B1X25vdGlmaWVyID0KK3sKKwkubm90aWZpZXJfY2FsbCA9IHRvcG9s b2d5X2NwdV9jYWxsYmFjaywKK307CisKK3N0YXRpYyBpbnQgX19jcHVpbml0IHRvcG9sb2d5X3N5 c2ZzX2luaXQodm9pZCkKK3sKKwlpbnQgaTsKKworCWNwdV90b3BvbG9neV9rb2JqZWN0ID0ga21h bGxvYyhzaXplb2Yoc3RydWN0IGtvYmplY3QpICogTlJfQ1BVUywKKwkJCUdGUF9LRVJORUwpOwor CWlmICghY3B1X3RvcG9sb2d5X2tvYmplY3QpCisJCXJldHVybiAtRU5PTUVNOworCisJZm9yX2Vh Y2hfb25saW5lX2NwdShpKSB7CisJCXRvcG9sb2d5X2NwdV9jYWxsYmFjaygmdG9wb2xvZ3lfY3B1 X25vdGlmaWVyLCBDUFVfT05MSU5FLAorCQkJCSh2b2lkICopKGxvbmcpaSk7CisJfQorCisJcmVn aXN0ZXJfY3B1X25vdGlmaWVyKCZ0b3BvbG9neV9jcHVfbm90aWZpZXIpOworCisJcmV0dXJuIDA7 Cit9CisKK2RldmljZV9pbml0Y2FsbCh0b3BvbG9neV9zeXNmc19pbml0KTsKKworI2VuZGlmIC8v Q09ORklHX1NNUAorI2VuZGlmCS8vQ09ORklHX1NZU0ZTCisK ------_=_NextPart_001_01C6005E.BBCEE0A4-- - 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/