Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2360936pxu; Mon, 7 Dec 2020 04:48:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqMWgEOTCYEbRc4oeQSYTL+HiLqE/H1lo28H6El/Ug8g5lK6Y4eKs0fDQsp3rvcxPqOTn5 X-Received: by 2002:a17:906:f894:: with SMTP id lg20mr18466607ejb.348.1607345321078; Mon, 07 Dec 2020 04:48:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607345321; cv=none; d=google.com; s=arc-20160816; b=RLnebFZxnVfxwpQhAdugSmuiqixIS+mo8svLtabXVXRIuEswzV0BUIhXjZaAxHaLb4 eFmYQZ3Nl3FAW2ByBMPqSScv+a7lqPuY35uiPW/NSsiH+PvaFYO3OZ3XRepfazCBbMxB jq5mOh6iD3ZhxcuURWkInyBa+TJgEnXRjOBGqrwTtNYAiF/k80mYqxkhVxaCX4WpGGcB UUDbTFtotVzfo/uHa/Jc1+auxu08NRQSwzEVT3Sj7Nd7gtsAClAz7AeBRtCNKtpwJ+gl jnMUwb8tYrMilMzmhqFabmbhyAyvqM9QTxhhyPQlkEARrYVQDYyRD6LXxmeAF1LeXwnh coiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=effV4eKUpZhOJaGdMrFLunZTIE1jehrc+23v+ZJ2gRc=; b=hmtTbbdQwus3J0hIfE2+LojDgdt48+ib0WG/GBUb/A8Zyc3IJZpAcp/F6/HV5I8/BP 0WRKZ0PbHnOqRayN4MJGSHfdTn7Bkrn4xXNwiWixqbzcHmUORioE2vFIPUt7hmGa2imL +6pZ0cQdk8w83hmpBMCbWCl+LQ+BBnsWDpM4ynFFrQN7avd/u09BRXTg+0r/ylsO8vbN cTuKfKR9Rrd+jkoomcMubU8RJwH+r+zQsvDc/iAhTfpdEf4ypY4+dEkyBcUyOKubzX13 vMfa9lBIV4Hbx/V62ZkTHulDJ4TKjYN00XoCGJkYt3vOnXvwS41aSOFWneiXs7m6HXT9 qsig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Jxz8ur8C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si7793768edq.353.2020.12.07.04.48.18; Mon, 07 Dec 2020 04:48:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=Jxz8ur8C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725924AbgLGMqz (ORCPT + 99 others); Mon, 7 Dec 2020 07:46:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:38490 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725550AbgLGMqz (ORCPT ); Mon, 7 Dec 2020 07:46:55 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1607345168; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=effV4eKUpZhOJaGdMrFLunZTIE1jehrc+23v+ZJ2gRc=; b=Jxz8ur8CMYKEwgIoP/8VeQbLaWeMMP6UZ0/Yv2EBdLdu5S0QwIntjPEFdCChUOzzrPFxGw 2UrZcP0qxYe9w35DtYdrYrfVcwnCd7hQc4CaE54kks7KEvLTJ0xHKJ3DSJNKsojz+iSOum tRsRYsnWo4CGvZkwWEYRi8+dN+UYnSQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8A68EAD09; Mon, 7 Dec 2020 12:46:08 +0000 (UTC) Date: Mon, 7 Dec 2020 13:46:08 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: vprintk_store: was: [PATCH next v2 3/3] printk: remove logbuf_lock, add syslog_lock Message-ID: References: <20201201205341.3871-1-john.ogness@linutronix.de> <20201201205341.3871-4-john.ogness@linutronix.de> <87k0tumusi.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87k0tumusi.fsf@jogness.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 2020-12-06 23:36:53, John Ogness wrote: > On 2020-12-04, Petr Mladek wrote: > >> + if (facility == 0) { > >> + while (text_len >= 2 && printk_get_level(text)) { > >> + text_len -= 2; > >> + text += 2; > >> + } > > > > We should avoid two completely different approaches > > that handle printk_level prefix. > > > > One solution is to implement something like: > > > > static char *parse_prefix(text, &level, &flags) > > > > That would return pointer to the text after the prefix. > > And fill level and flags only when non-NULL pointers are passed. > > OK. > > > Another solution would be to pass this information from > > vprintk_store(). The prefix has already been parsed > > after all. > > Well, there is a vscnprintf() that happens in between and I don't think > we should trust the parsed offset from the first vsnprintf(). Good point! > >> + > >> + if (text != orig_text) > >> + memmove(orig_text, text, text_len); > >> + } > > > > We should clear the freed space to make the ring buffer as > > human readable as possible when someone just dumps the memory. > > Data blocks are currently padded and that padding is not cleared. So it > is already not perfectly human readable on a raw dump. It would be nice to clean up the padding as well. But it is a cosmetic improvement that might be done anytime later. > > Sigh, I have to admit that I missed the problem with prefix and > > trailing '\n' when I suggested to avoid the temporary buffers. > > This memmove() and the space wasting is pity. > > > > Well, it is typically 3 bytes per message. And the copying would > > be necessary even with the temporary buffer. So, I am less convinced > > but I would still try to avoid the temporary buffers for now. > > Agreed. I think this approach is better than the temporary buffers I > previously used. Another motivation is that it allows to simply handle recursion/nesting. Othrewise, we would need temporary buffers for each allowed recursion level or some tricky code. > Also, if we add a trimming feature to the ringbuffer, > it will keep the ringbuffer mostly clean anyway. Something like this: > > prb_rec_init_wr(&r, text_len); > prb_reserve(&e, prb, &r); > text_len = printk_sprint(&r.text_buf[0], text_len, ...); > r.info->text_len = text_len; > prb_trim_rec(&e, &r); <--- try to reduce datablock size to @text_len > prb_commit(&e); > > I see no urgency to add such a feature. But I think we should keep it on > our radar. Yup. I thought about it as well. I agree that it is not a priority. Best Regards, Petr