[{"id":1610080,"web_url":"http://patchwork.ozlabs.org/comment/1610080/","msgid":"<20170317050930.GB28075@kroah.com>","date":"2017-03-17T05:09:30","subject":"Re: [PATCH] tty: hvc: don't allocate a buffer for console print on\n\tstack","submitter":{"id":11800,"url":"http://patchwork.ozlabs.org/api/people/11800/","name":"Greg Kroah-Hartman","email":"gregkh@linuxfoundation.org"},"content":"On Fri, Feb 17, 2017 at 11:42:45PM +0300, Jan Dakinevich wrote:\n> The buffer is used by virtio console driver as DMA buffer. Since v4.9\n> (if VMAP_STACK is enabled) we shouldn't use the stack for DMA.\n\nYou shouldn't use 'static' data either, that's not always guaranteed to\nbe DMA-able, right?\n\n> \n> Signed-off-by: Jan Dakinevich <jan.dakinevich@gmail.com>\n> ---\n>  drivers/tty/hvc/hvc_console.c | 7 ++++++-\n>  1 file changed, 6 insertions(+), 1 deletion(-)\n> \n> diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c\n> index 9b5c0fb..1ce6aaf 100644\n> --- a/drivers/tty/hvc/hvc_console.c\n> +++ b/drivers/tty/hvc/hvc_console.c\n> @@ -143,10 +143,15 @@ static struct hvc_struct *hvc_get_by_index(int index)\n>  static void hvc_console_print(struct console *co, const char *b,\n>  \t\t\t      unsigned count)\n>  {\n> -\tchar c[N_OUTBUF] __ALIGNED__;\n>  \tunsigned i = 0, n = 0;\n>  \tint r, donecr = 0, index = co->index;\n>  \n> +\t/*\n> +\t * Access to the buffer is serialized by console_sem in caller code from\n> +\t * kernel/printk/printk.c\n> +\t */\n> +\tstatic char c[N_OUTBUF] __ALIGNED__;\n\nWhat about allocating it dynamically?  That's the correct thing to do.\n\nthanks,\n\ngreg k-h","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 3vktjM2NqGz9s0Z\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 17 Mar 2017 16:11:19 +1100 (AEDT)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3vktjM1K1CzDqf2\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 17 Mar 2017 16:11:19 +1100 (AEDT)","from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3vktgb0yRHzDqc4\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 17 Mar 2017 16:09:46 +1100 (AEDT)","from localhost (unknown [166.170.37.132])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPSA id F26025AA;\n\tFri, 17 Mar 2017 05:09:43 +0000 (UTC)"],"Date":"Fri, 17 Mar 2017 14:09:30 +0900","From":"Greg Kroah-Hartman <gregkh@linuxfoundation.org>","To":"Jan Dakinevich <jan.dakinevich@gmail.com>","Subject":"Re: [PATCH] tty: hvc: don't allocate a buffer for console print on\n\tstack","Message-ID":"<20170317050930.GB28075@kroah.com>","References":"<1487364165-21882-1-git-send-email-jan.dakinevich@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<1487364165-21882-1-git-send-email-jan.dakinevich@gmail.com>","User-Agent":"Mutt/1.8.0 (2017-02-23)","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":"Peter Hurley <peter@hurleysoftware.com>, Arnd Bergmann <arnd@arndb.de>, \n\tAmit Shah <amit@kernel.org>, linux-kernel@vger.kernel.org,\n\tvirtualization@lists.linux-foundation.org, Jiri Slaby <jslaby@suse.com>, \n\tlinuxppc-dev@lists.ozlabs.org, Dan Carpenter <dan.carpenter@oracle.com>","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":1612109,"web_url":"http://patchwork.ozlabs.org/comment/1612109/","msgid":"<18f113d4-9c37-0114-d637-3720ad093722@gmail.com>","date":"2017-03-20T15:55:15","subject":"Re: [PATCH] tty: hvc: don't allocate a buffer for console print on\n\tstack","submitter":{"id":71018,"url":"http://patchwork.ozlabs.org/api/people/71018/","name":"Jan Dakinevich","email":"jan.dakinevich@gmail.com"},"content":"> You shouldn't use 'static' data either, that's not always guaranteed to\n> be DMA-able, right?\n\nI naively thought all 'static' data was linked into .data and the\nsection was always kmapped.\n\n> What about allocating it dynamically?  That's the correct thing to do.\n\nYep, the solution was more welcomed and happened earlier:\nhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c4baad50297d84bde1a7ad45e50c73adae4a2192\n\nOn 03/17/2017 08:09 AM, Greg Kroah-Hartman wrote:\n> On Fri, Feb 17, 2017 at 11:42:45PM +0300, Jan Dakinevich wrote:\n>> The buffer is used by virtio console driver as DMA buffer. Since v4.9\n>> (if VMAP_STACK is enabled) we shouldn't use the stack for DMA.\n> \n> You shouldn't use 'static' data either, that's not always guaranteed to\n> be DMA-able, right?\n> \n>>\n>> Signed-off-by: Jan Dakinevich <jan.dakinevich@gmail.com>\n>> ---\n>>  drivers/tty/hvc/hvc_console.c | 7 ++++++-\n>>  1 file changed, 6 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c\n>> index 9b5c0fb..1ce6aaf 100644\n>> --- a/drivers/tty/hvc/hvc_console.c\n>> +++ b/drivers/tty/hvc/hvc_console.c\n>> @@ -143,10 +143,15 @@ static struct hvc_struct *hvc_get_by_index(int index)\n>>  static void hvc_console_print(struct console *co, const char *b,\n>>  \t\t\t      unsigned count)\n>>  {\n>> -\tchar c[N_OUTBUF] __ALIGNED__;\n>>  \tunsigned i = 0, n = 0;\n>>  \tint r, donecr = 0, index = co->index;\n>>  \n>> +\t/*\n>> +\t * Access to the buffer is serialized by console_sem in caller code from\n>> +\t * kernel/printk/printk.c\n>> +\t */\n>> +\tstatic char c[N_OUTBUF] __ALIGNED__;\n> \n> What about allocating it dynamically?  That's the correct thing to do.\n> \n> thanks,\n> \n> greg k-h\n>","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 3vn0vW0mXdz9s3w\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 21 Mar 2017 02:57:27 +1100 (AEDT)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3vn0vV6mpJzDqcD\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 21 Mar 2017 02:57:26 +1100 (AEDT)","from mail-lf0-x241.google.com (mail-lf0-x241.google.com\n\t[IPv6:2a00:1450:4010:c07::241])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3vn0rP0DDpzDq5g\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tTue, 21 Mar 2017 02:54:45 +1100 (AEDT)","by mail-lf0-x241.google.com with SMTP id r36so10695071lfi.0\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tMon, 20 Mar 2017 08:54:44 -0700 (PDT)","from [127.0.0.1] (host5.infotecs.ru. [91.244.183.5])\n\tby smtp.gmail.com with ESMTPSA id\n\tm2sm346075lfg.35.2017.03.20.08.54.40\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 20 Mar 2017 08:54:40 -0700 (PDT)"],"Authentication-Results":["ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"pOXKdqn0\"; dkim-atps=neutral","lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"pOXKdqn0\"; dkim-atps=neutral","lists.ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"pOXKdqn0\"; dkim-atps=neutral"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=subject:to:references:cc:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-transfer-encoding;\n\tbh=ArZdnG716+9FyxmseF5AT2zBbc0SEF+dRJS7V2vZedo=;\n\tb=pOXKdqn0r7vZ5Jzchraf4y1v4RvcfC8FP/ukHOMugBi45j4Onu4oD1++VG974JKVoi\n\tJdrFsDusxBDh5sbVY9Uy4GKUNk5+u/N4SLvfGF8d+0MwnZdHh2ka9bEp8fcy0vxNAJIv\n\tJvrvKY6KlgG9zXbGMLO4wLhZN/V3WQhiH4nGUu+L6/u7hyAh3rbNmDE5lhqilVOTSG+L\n\tJ50LUiRmT34Wx30CHU1ONYYqa1HxZTIhErwyv4YG3KKA4ETpBn9v1bMe6gt/lTMQgYmH\n\tqrehONklOaAfQk9ZRlamZVA1hKNKNimRohZNyq2OyyMpc/iX0Vr20C2I9mZBnzvMTe8t\n\tN0Fg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:references:cc:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-transfer-encoding;\n\tbh=ArZdnG716+9FyxmseF5AT2zBbc0SEF+dRJS7V2vZedo=;\n\tb=Zp0ihGNeXhMBLdARrBTWZAZUwloStBRVkFVbUgUUadrfuNbmsTSSUqJPc14Ip0ykfc\n\tJpaCAtos8VK2V9xoa4enRzR0VAJUMjRhaWDL6uLEB8ZBXfbXwXvOrT/LZP8q6laoKqWU\n\t/Bd+RW9Uj82TdrXeYlzLgnN0K0G+VnSecyWiYF14hVSNA6svYkrb43ygexGDo+qbfw6F\n\tZ3f/LZFZSWBayIvVpHMOykjtiC1KDbuVFtDbbfyCK4LPsKCw5Ar+6f3VWpAlABBeFyvh\n\tXsBrI1K2W/Zar3TJGAiPEALYdCyJa8oYrlJcZ88WQUbJV1Sl8BefkZcG7rNfg8H3/ZT+\n\tNpNQ==","X-Gm-Message-State":"AFeK/H3V/3WsYeGWxUvu2hd+DfqIDJlIgRjrchOUgTgSWLn44TkZpt/bwcjnkoHgvsKyEg==","X-Received":"by 10.25.205.149 with SMTP id d143mr8314753lfg.65.1490025281786; \n\tMon, 20 Mar 2017 08:54:41 -0700 (PDT)","Subject":"Re: [PATCH] tty: hvc: don't allocate a buffer for console print on\n\tstack","To":"Greg Kroah-Hartman <gregkh@linuxfoundation.org>","References":"<1487364165-21882-1-git-send-email-jan.dakinevich@gmail.com>\n\t<20170317050930.GB28075@kroah.com>","From":"Jan Dakinevich <jan.dakinevich@gmail.com>","Message-ID":"<18f113d4-9c37-0114-d637-3720ad093722@gmail.com>","Date":"Mon, 20 Mar 2017 18:55:15 +0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.7.0","MIME-Version":"1.0","In-Reply-To":"<20170317050930.GB28075@kroah.com>","Content-Type":"text/plain; charset=windows-1252","Content-Transfer-Encoding":"7bit","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":"Peter Hurley <peter@hurleysoftware.com>, Arnd Bergmann <arnd@arndb.de>, \n\tAmit Shah <amit@kernel.org>, linux-kernel@vger.kernel.org,\n\tvirtualization@lists.linux-foundation.org, Jiri Slaby <jslaby@suse.com>, \n\tlinuxppc-dev@lists.ozlabs.org, Dan Carpenter <dan.carpenter@oracle.com>","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>"}}]