Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1147202imj; Sat, 16 Feb 2019 22:25:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IYg8kTMhZa8GjXHyJEmIlQlTzVU0DupIAyEdY1BoywGtC39v9pmXfTFTx0ME/+pDe9FgGnd X-Received: by 2002:aa7:83c2:: with SMTP id j2mr17833420pfn.119.1550384713878; Sat, 16 Feb 2019 22:25:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550384713; cv=none; d=google.com; s=arc-20160816; b=0ZMUlpZlgljVSENCbPR2b4UvwsmLGkeRRoZ0cJY/a/8Mt8SLXeCdekICLkdRansMnB qavIVBDPCIUHPZHj+zu/MUW6RlnpllLx69fW2CMcKsJLiiq1B9dit+t2RCHnb5gBS2pz QaqssjngGdIyFG7dTfEajXu/6Pj39c1XWanQryJghDiOSF9KT0KyPQjcVMy4zvU+xwh9 8MCvX5IxN7ZWZi/DlS3Mf77ylnT7YqmUivJixZ0Ay1QKOXphfyR15ka4TWf4aGb5QGCt iUmGQdBw8KnendmK8mNuX0YjKRr3faSObeK8M6b3pP5ltLEk1R9iQ3KgVwHn5j13AbJr bgnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9AZRpga7WZSwULEfcZxbF8AYTLLB/CdEksXg9BuCwV4=; b=mUYOCtuV4AW7x+re+PrnpTXNkfq86YnJ8YsYQOZ9Xqnb7mEsa29jjcqnSBxpNgMo9m 3n+Q8McaSvkAm5TqLMndYwP4z4eABjNFe5ywyJA1EbX4Q7BneJs5MnjV7WNTiIX4aok6 34Su86KlTOh1AnZUTeR57hjpHbomU9sr6YwKpKFmpAgfOH9T7vhGKNyAW2iFdNO4WEm6 dxYTu/HgAe3ETbbh5yu1MSsmMlEaRw746vFF6e4LWpsJ9H1J47SzOApwlkeevPOMHlel 8KFJLzt/+vsWlrwpb91wbxiea76UEdt/KNNhD27hfZ+oD89bzAatFsdc6sL9G90wdUtu 9DUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RXwQlNwe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 98si10301326pls.205.2019.02.16.22.24.58; Sat, 16 Feb 2019 22:25:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RXwQlNwe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731471AbfBPQwR (ORCPT + 99 others); Sat, 16 Feb 2019 11:52:17 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:38640 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730824AbfBPQwR (ORCPT ); Sat, 16 Feb 2019 11:52:17 -0500 Received: by mail-qk1-f196.google.com with SMTP id p15so7611325qkl.5; Sat, 16 Feb 2019 08:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9AZRpga7WZSwULEfcZxbF8AYTLLB/CdEksXg9BuCwV4=; b=RXwQlNweEgqjMfrSqzM7TqF8kwqLWyA32uf1nw2fQEHwr5dOufxFFnfNbsc8a4NnmW FyvWa8qdS94xxxzozhEuZgVAXSo++CaYPXFWlJusbI0JKKXu30EZ7Uvt8t20IkPT/pap /Ac/Tt4clhovyFLBATaYzuBExyoBb2TgyFngnPjav0P6tIHvmYQ9l3P81RkaugfhnlV1 hoOUWHojcNGRGt6KmJjAFhTR3WvF6MYkcoS5SmRJUi3Fipv88hV0123Uxf/a4uCOHov9 k1zCnz4pRk8WpVAnyI6cwsKT5b3/MU41wZE28JsyQhERYog1bWDheTHko6lex4cWDrot 4zTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9AZRpga7WZSwULEfcZxbF8AYTLLB/CdEksXg9BuCwV4=; b=jlkjSTkakaXf6odMxvgGkRXJ2UPNQ0vGZbxd8Tt9uT8fpdHtWrQuif6rdgbN285Kyl YshSA1b30JDqNyK+N9RO4A72CA7uwWry5U3YsL4OlpBmhBLlA/JgHta5BO0yjKLsEEcm lIn1ryg311rkHNZ0tCcLpD0BUuxX1ueKmhzP+uX824AHxyjFGnyPdvY7gENQBm7JT80K RVboPH+zp1yNaxgaLM01IaNhe1QgJKkrSA8xZ9K6pXuWKQJcD6hdAa0v1FCMvJpsZqBk 2XnkmcQcXOL54uEE1CcqVMK4CvuzaRQ3TgKleCJ83jNQgiQV1AqQyFEXwQqvGso5iv9J yIpA== X-Gm-Message-State: AHQUAuaPoYYbYa0FWAL2owb2N3ROHuHZS7WlvB+rXnYkxf6VzhYTf/Ww XXQeesIN1tAhgfHZPjO14dH/CDizhH99nhTmGhY= X-Received: by 2002:ae9:c106:: with SMTP id z6mr11046961qki.197.1550335935723; Sat, 16 Feb 2019 08:52:15 -0800 (PST) MIME-Version: 1.0 References: <1550124158-1111-1-git-send-email-xiaoxiang@xiaomi.com> <1550124158-1111-2-git-send-email-xiaoxiang@xiaomi.com> <20190214130940.GV9224@smile.fi.intel.com> <20190215150620.GB9224@smile.fi.intel.com> In-Reply-To: <20190215150620.GB9224@smile.fi.intel.com> From: xiang xiao Date: Sun, 17 Feb 2019 00:52:04 +0800 Message-ID: Subject: Re: [PATCH V2 2/2] rpmsg: add syslog redirection driver To: Andy Shevchenko Cc: Randy Dunlap , Greg KH , alexander.shishkin@linux.intel.com, Ohad Ben Cohen , Bjorn Andersson , wendy.liang@xilinx.com, Arnaud POULIQUEN , Kumar Gala , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Guiding Li Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 15, 2019 at 11:06 PM Andy Shevchenko wrote: > > On Fri, Feb 15, 2019 at 12:31:17AM +0800, xiang xiao wrote: > > On Thu, Feb 14, 2019 at 9:09 PM Andy Shevchenko > > wrote: > > > On Thu, Feb 14, 2019 at 02:02:38PM +0800, Xiang Xiao wrote: > > > > > This driver allows the remote processor to redirect the output of > > > > syslog or printf into the kernel log, which is very useful to see > > > > what happen in the remote side. > > > > > > > +struct rpmsg_syslog_header { > > > > + u32 command; > > > > + s32 result; > > > > +} __packed; > > > > > > Isn't packed already? > > > > > > > But, I want to make it more explicitly and prepare for struct expansion later. > > How? Why it's not in this patch / patch series? Just for future, not now:). Since this structure is shared by the different CPU/OS, it's better to indicate the packed explicitly. > > > > > + /* output the message before '\n' to the kernel log */ > > > > + nl = memrchr(msg->data, '\n', msg->count); > > > > > > Hmm... To me it sounds somehow fragile. > > > > > > If your text contains binary data, how can you guarantee that it would be not > > > in the middle of two \n:s? > > > > This driver is just for log/printf redirection, so we could safely > > assume the data is pure text. > > Then I don't see a point to use memrchr() at all here. > > Use strchr or strrchr(). Yes, use strnchr is enough, I will remove memrchr in the next review. > > > > OTOH, if it text data, why do you need to take all strings at once? > > > > Remote side may decide to buffer more log to reduce the IPC number > > since IPC is a time consuming operation. > > So, you always can do something like > > p = msg->data; > while (...strsep(..., "\n")) { > pr_info("%s\n", token); > ... > } Can't use strsep here, since log come from remote isn't terminated by '\0'. > > > > > > It might be worse from performance prospective (if you know how and when printk() supplies buffer to the console). > > > > Yes, it's very slow if the log send to serial console. But in > > production environment, printk normally just save in ram and viewed by > > dmesg which is very fast. > > You may not do such assumptions. For someone it would be RAM, for some > customers it might be a slow channel. But we need reduce the IPC number, so both fast/slow channel could get the benefit. > > > > > > + strncpy(priv->buf + priv->next, msg->data + printed, copied); > > > > > > Hmm... shouldn't be memcpy()? > > > > I use memcpy initially, but found that the unaligned exception happen randomly. > > To avoid the cache issue, the IPC memory normally map as device memory, but > > ARM just allow the alignment access to this type of memory. > > So, than it's an architecture level issue. With strncpy() here you will get a > pretty rightful GCC warning. > Why GCC warning strncpy here? > > > > + /* flush the buffered log if need */ > > > > + if (priv->next) > > > > + pr_info("%.*s\n", priv->next, priv->buf); > > > > + kfree(priv->buf); > > > > > > I don't see how it's serialized. Does rpmsg core take care of this? > > > > Yes, the callback come from a dedicated work thread. > > Please, add a comment explaining that. > Will add in the next review. > -- > With Best Regards, > Andy Shevchenko > >