[{"id":1756231,"web_url":"http://patchwork.ozlabs.org/comment/1756231/","msgid":"<871so1w86g.fsf@concordia.ellerman.id.au>","date":"2017-08-24T10:51:03","subject":"Re: [PATCH 4/4] powerpc/32: remove a NOP from memset()","submitter":{"id":46580,"url":"http://patchwork.ozlabs.org/api/people/46580/","name":"Michael Ellerman","email":"mpe@ellerman.id.au"},"content":"Christophe Leroy <christophe.leroy@c-s.fr> writes:\n\n> memset() is patched after initialisation to activate the\n> optimised part which uses cache instructions.\n>\n> Today we have a 'b 2f' to skip the optimised patch, which then gets\n> replaced by a NOP, implying a useless cycle consumption.\n> As we have a 'bne 2f' just before, we could use that instruction\n> for the live patching, hence removing the need to have a\n> dedicated 'b 2f' to be replaced by a NOP.\n>\n> This patch changes the 'bne 2f' by a 'b 2f'. During init, that\n> 'b 2f' is then replaced by 'bne 2f'\n\nI'm not sure what the sequence is during boot for the 32-bit code, but\ncan you use an ALT_FTR section for this? Possibly that doesn't get done\nat the right time though.\n\ncheers","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xdLjF63Mzz9s65\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 24 Aug 2017 20:52:33 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xdLjF4hHWzDrMn\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 24 Aug 2017 20:52:33 +1000 (AEST)","from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xdLgX4TwgzDrKv\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tThu, 24 Aug 2017 20:51:04 +1000 (AEST)","from authenticated.ozlabs.org (localhost [127.0.0.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPSA id 3xdLgX2S8vz9s65;\n\tThu, 24 Aug 2017 20:51:04 +1000 (AEST)"],"From":"Michael Ellerman <mpe@ellerman.id.au>","To":"Christophe Leroy <christophe.leroy@c-s.fr>,\n\tBenjamin Herrenschmidt <benh@kernel.crashing.org>,\n\tPaul Mackerras <paulus@samba.org>, Scott Wood <oss@buserror.net>","Subject":"Re: [PATCH 4/4] powerpc/32: remove a NOP from memset()","In-Reply-To":"<ae2205dedfe437e4df2dd0cc7605d62189833221.1503277387.git.christophe.leroy@c-s.fr>","References":"<cover.1503277387.git.christophe.leroy@c-s.fr>\n\t<ae2205dedfe437e4df2dd0cc7605d62189833221.1503277387.git.christophe.leroy@c-s.fr>","User-Agent":"Notmuch/0.21 (https://notmuchmail.org)","Date":"Thu, 24 Aug 2017 20:51:03 +1000","Message-ID":"<871so1w86g.fsf@concordia.ellerman.id.au>","MIME-Version":"1.0","Content-Type":"text/plain","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}},{"id":1756412,"web_url":"http://patchwork.ozlabs.org/comment/1756412/","msgid":"<4fcbdc51-b170-d4a2-5344-c55b2ec71cbb@c-s.fr>","date":"2017-08-24T13:58:41","subject":"Re: [PATCH 4/4] powerpc/32: remove a NOP from memset()","submitter":{"id":5234,"url":"http://patchwork.ozlabs.org/api/people/5234/","name":"Christophe Leroy","email":"christophe.leroy@c-s.fr"},"content":"Le 24/08/2017 à 12:51, Michael Ellerman a écrit :\n> Christophe Leroy <christophe.leroy@c-s.fr> writes:\n> \n>> memset() is patched after initialisation to activate the\n>> optimised part which uses cache instructions.\n>>\n>> Today we have a 'b 2f' to skip the optimised patch, which then gets\n>> replaced by a NOP, implying a useless cycle consumption.\n>> As we have a 'bne 2f' just before, we could use that instruction\n>> for the live patching, hence removing the need to have a\n>> dedicated 'b 2f' to be replaced by a NOP.\n>>\n>> This patch changes the 'bne 2f' by a 'b 2f'. During init, that\n>> 'b 2f' is then replaced by 'bne 2f'\n> \n> I'm not sure what the sequence is during boot for the 32-bit code, but\n> can you use an ALT_FTR section for this? Possibly that doesn't get done\n> at the right time though.\n\nUnfortunately, as we discussed in 2015 \n(https://lkml.org/lkml/2015/9/10/608), the ALT_FTR does things too \nearly, while the cache is not enabled yet.\n\nChristophe","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xdQsg28XCz9s03\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 25 Aug 2017 00:00:07 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xdQsf6bZ9zDrJY\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 25 Aug 2017 00:00:06 +1000 (AEST)","from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xdQr60YsLzDrJ3\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tThu, 24 Aug 2017 23:58:46 +1000 (AEST)","from localhost (mailhub1-int [192.168.12.234])\n\tby localhost (Postfix) with ESMTP id 3xdQqm0LZNz9ttFl;\n\tThu, 24 Aug 2017 15:58:28 +0200 (CEST)","from pegase1.c-s.fr ([192.168.12.234])\n\tby localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id DttLb6ih5QQl; Thu, 24 Aug 2017 15:58:27 +0200 (CEST)","from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192])\n\tby pegase1.c-s.fr (Postfix) with ESMTP id 3xdQql6x28z9ttFY;\n\tThu, 24 Aug 2017 15:58:27 +0200 (CEST)","from localhost (localhost [127.0.0.1])\n\tby messagerie.si.c-s.fr (Postfix) with ESMTP id 58EE88B869;\n\tThu, 24 Aug 2017 15:58:41 +0200 (CEST)","from messagerie.si.c-s.fr ([127.0.0.1])\n\tby localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new,\n\tport 10023)\n\twith ESMTP id zWY9xCu-hq-1; Thu, 24 Aug 2017 15:58:41 +0200 (CEST)","from PO15451 (po15451.idsi0.si.c-s.fr [172.25.231.1])\n\tby messagerie.si.c-s.fr (Postfix) with ESMTP id 2CC228B770;\n\tThu, 24 Aug 2017 15:58:41 +0200 (CEST)"],"X-Virus-Scanned":["Debian amavisd-new at c-s.fr","amavisd-new at c-s.fr"],"Subject":"Re: [PATCH 4/4] powerpc/32: remove a NOP from memset()","To":"Michael Ellerman <mpe@ellerman.id.au>,\n\tBenjamin Herrenschmidt <benh@kernel.crashing.org>,\n\tPaul Mackerras <paulus@samba.org>, Scott Wood <oss@buserror.net>","References":"<cover.1503277387.git.christophe.leroy@c-s.fr>\n\t<ae2205dedfe437e4df2dd0cc7605d62189833221.1503277387.git.christophe.leroy@c-s.fr>\n\t<871so1w86g.fsf@concordia.ellerman.id.au>","From":"Christophe LEROY <christophe.leroy@c-s.fr>","Message-ID":"<4fcbdc51-b170-d4a2-5344-c55b2ec71cbb@c-s.fr>","Date":"Thu, 24 Aug 2017 15:58:41 +0200","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<871so1w86g.fsf@concordia.ellerman.id.au>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"fr","Content-Transfer-Encoding":"8bit","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}},{"id":1756908,"web_url":"http://patchwork.ozlabs.org/comment/1756908/","msgid":"<87k21sv6yb.fsf@concordia.ellerman.id.au>","date":"2017-08-25T00:15:08","subject":"Re: [PATCH 4/4] powerpc/32: remove a NOP from memset()","submitter":{"id":46580,"url":"http://patchwork.ozlabs.org/api/people/46580/","name":"Michael Ellerman","email":"mpe@ellerman.id.au"},"content":"Christophe LEROY <christophe.leroy@c-s.fr> writes:\n\n> Le 24/08/2017 à 12:51, Michael Ellerman a écrit :\n>> Christophe Leroy <christophe.leroy@c-s.fr> writes:\n>> \n>>> memset() is patched after initialisation to activate the\n>>> optimised part which uses cache instructions.\n>>>\n>>> Today we have a 'b 2f' to skip the optimised patch, which then gets\n>>> replaced by a NOP, implying a useless cycle consumption.\n>>> As we have a 'bne 2f' just before, we could use that instruction\n>>> for the live patching, hence removing the need to have a\n>>> dedicated 'b 2f' to be replaced by a NOP.\n>>>\n>>> This patch changes the 'bne 2f' by a 'b 2f'. During init, that\n>>> 'b 2f' is then replaced by 'bne 2f'\n>> \n>> I'm not sure what the sequence is during boot for the 32-bit code, but\n>> can you use an ALT_FTR section for this? Possibly that doesn't get done\n>> at the right time though.\n>\n> Unfortunately, as we discussed in 2015 \n> (https://lkml.org/lkml/2015/9/10/608),\n\nHaha, you expect me to remember things I said then! ;)\n\n> the ALT_FTR does things too early, while the cache is not enabled yet.\n\nOK. Ben did do some reworks to the early init since then, but I don't\nthink he changed that.\n\nI notice we do setup_feature_keys() in machine_init(), which is the jump\nlabel equivalent of apply_feature_fixups(). So I wonder if we could\nactually move apply_feature_fixups() to there. But it would need some\nserious review.\n\ncheers","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xdhXj4PQMz9t3m\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 25 Aug 2017 10:16:21 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xdhXj3P1BzDrL2\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 25 Aug 2017 10:16:21 +1000 (AEST)","from ozlabs.org (bilbo.ozlabs.org [103.22.144.67])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xdhWJ3JRbzDrJx\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 25 Aug 2017 10:15:08 +1000 (AEST)","from authenticated.ozlabs.org (localhost [127.0.0.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPSA id 3xdhWJ1y08z9t3m;\n\tFri, 25 Aug 2017 10:15:08 +1000 (AEST)"],"From":"Michael Ellerman <mpe@ellerman.id.au>","To":"Christophe LEROY <christophe.leroy@c-s.fr>,\n\tBenjamin Herrenschmidt <benh@kernel.crashing.org>,\n\tPaul Mackerras <paulus@samba.org>, Scott Wood <oss@buserror.net>","Subject":"Re: [PATCH 4/4] powerpc/32: remove a NOP from memset()","In-Reply-To":"<4fcbdc51-b170-d4a2-5344-c55b2ec71cbb@c-s.fr>","References":"<cover.1503277387.git.christophe.leroy@c-s.fr>\n\t<ae2205dedfe437e4df2dd0cc7605d62189833221.1503277387.git.christophe.leroy@c-s.fr>\n\t<871so1w86g.fsf@concordia.ellerman.id.au>\n\t<4fcbdc51-b170-d4a2-5344-c55b2ec71cbb@c-s.fr>","User-Agent":"Notmuch/0.21 (https://notmuchmail.org)","Date":"Fri, 25 Aug 2017 10:15:08 +1000","Message-ID":"<87k21sv6yb.fsf@concordia.ellerman.id.au>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}}]