Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757496Ab2JLDKv (ORCPT ); Thu, 11 Oct 2012 23:10:51 -0400 Received: from mga11.intel.com ([192.55.52.93]:17523 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754087Ab2JLDKu (ORCPT ); Thu, 11 Oct 2012 23:10:50 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,576,1344236400"; d="scan'208";a="233010587" From: "Ma, Ling" To: Andi Kleen CC: "mingo@elte.hu" , "hpa@zytor.com" , "tglx@linutronix.de" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH RFC 2/2] [x86] Optimize copy_page by re-arranging instruction sequence and saving register Thread-Topic: [PATCH RFC 2/2] [x86] Optimize copy_page by re-arranging instruction sequence and saving register Thread-Index: AQHNp3KHe7EK2OTz7EWBVGWon0YSZpe0HToigADK2YA= Date: Fri, 12 Oct 2012 03:10:45 +0000 Message-ID: References: <1349958548-1868-1-git-send-email-ling.ma@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: multipart/mixed; boundary="_002_B2310DA9850C8743AA7AA0055500E90F0FD709C4SHSMSX102ccrcor_" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6385 Lines: 113 --_002_B2310DA9850C8743AA7AA0055500E90F0FD709C4SHSMSX102ccrcor_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > > Load and write operation occupy about 35% and 10% respectively for > > most industry benchmarks. Fetched 16-aligned bytes code include about > > 4 instructions, implying 1.34(0.35 * 4) load, 0.4 write. > > Modern CPU support 2 load and 1 write per cycle, so throughput from > > write is bottleneck for memcpy or copy_page, and some slight CPU only > > support one mem operation per cycle. So it is enough to issue one > read > > and write instruction per cycle, and we can save registers. >=20 > I don't think "saving registers" is a useful goal here. Ling: issuing one read and write ops in one cycle is enough for copy_page o= r memcpy performance, so we could avoid saving and restoring registers operation. > > > > In this patch we also re-arrange instruction sequence to improve > > performance The performance on atom is improved about 11%, 9% on > > hot/cold-cache case respectively. >=20 > That's great, but the question is what happened to the older CPUs that > also this sequence. It may be safer to add a new variant for Atom, > unless you can benchmark those too. Ling:=20 I tested new and original version on core2, the patch improved performance = about 9%, Although core2 is out-of-order pipeline and weaken instruction sequence req= uirement,=20 because of ROB size limitation, new patch issues write operation earlier an= d get more parallelism possibility for the pair of write and load ops and bet= ter result. Attached core2-cpu-info (I have no older machine) Thanks Ling =20 --_002_B2310DA9850C8743AA7AA0055500E90F0FD709C4SHSMSX102ccrcor_ Content-Type: application/octet-stream; name="core2-cpu-info" Content-Description: core2-cpu-info Content-Disposition: attachment; filename="core2-cpu-info"; size=2992; creation-date="Fri, 12 Oct 2012 03:03:13 GMT"; modification-date="Fri, 12 Oct 2012 03:03:07 GMT" Content-Transfer-Encoding: base64 cHJvY2Vzc29yCTogMAp2ZW5kb3JfaWQJOiBHZW51aW5lSW50ZWwKY3B1IGZhbWlseQk6IDYKbW9k ZWwJCTogMTUKbW9kZWwgbmFtZQk6IEludGVsKFIpIENvcmUoVE0pMiBRdWFkIENQVSAgICBRNjYw MCAgQCAyLjQwR0h6CnN0ZXBwaW5nCTogMTEKY3B1IE1IegkJOiAyNDAwLjAwMwpjYWNoZSBzaXpl CTogNDA5NiBLQgpwaHlzaWNhbCBpZAk6IDAKc2libGluZ3MJOiA0CmNvcmUgaWQJCTogMApjcHUg Y29yZXMJOiA0CmFwaWNpZAkJOiAwCmluaXRpYWwgYXBpY2lkCTogMApmcHUJCTogeWVzCmZwdV9l eGNlcHRpb24JOiB5ZXMKY3B1aWQgbGV2ZWwJOiAxMAp3cAkJOiB5ZXMKZmxhZ3MJCTogZnB1IHZt ZSBkZSBwc2UgdHNjIG1zciBwYWUgbWNlIGN4OCBhcGljIHNlcCBt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nb29kIGFwZXJmbXBlcmYgcG5pIGR0ZXM2NCBtb25pdG9yIGRzX2Nw bCB2bXggZXN0IHRtMiBzc3NlMyBjeDE2IHh0cHIgcGRjbSBsYWhmX2xtIHRwcl9zaGFkb3cgdm5t aSBmbGV4cHJpb3JpdHkKYm9nb21pcHMJOiA0Nzg3Ljc2CmNsZmx1c2ggc2l6ZQk6IDY0CmNhY2hl X2FsaWdubWVudAk6IDY0CmFkZHJlc3Mgc2l6ZXMJOiAzNiBiaXRzIHBoeXNpY2FsLCA0OCBiaXRz IHZpcnR1YWwKcG93ZXIgbWFuYWdlbWVudDoKCg== --_002_B2310DA9850C8743AA7AA0055500E90F0FD709C4SHSMSX102ccrcor_-- -- 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/