Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1255554ybt; Thu, 25 Jun 2020 01:20:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/OwGOOmNpais08HA1pS3uoiTjLNDnHaqDHnPGgBc4l4tbSOxg6fuSM0Xnuz29X+wYcmZa X-Received: by 2002:a05:6402:94f:: with SMTP id h15mr817893edz.313.1593073227075; Thu, 25 Jun 2020 01:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593073227; cv=none; d=google.com; s=arc-20160816; b=iO+pBURRRm7sCjMeGTyC8fylolVqPI+ZFb089fx3mDcq28jLxzZwyNxIqOBOOF4tFa GaowXZ7amfwwGWES6RcOSVaildGTgpebwS8zntNSHalOuAFxoGxVaxm021dZKZ5reo/S DgsRqwbZQ8mX8arDZ587wYnV+mmJ5jGBU0q4rcLTOfQy2HSM8WYfNMGavqO1sB5h+P4c OUf7uisTGAeDuvHcuT82zYb3Vv6IeX++F5cYE6qwM3iUz3OhQlj3b9l0kSAetAGXvk/p JlRX5ztRfJkMccGTmspMZsbRTPbi+CjDIIVQa9XQ2yugu0dWgxeJeXh7UBkjC3cfWGzv /oAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=C2XoRr8RZ2CcYQznIOPrU41KWLQIB85QCHR4xnKY7ik=; b=LPwYNlCJISGCWVfQI8PKuXoe/psiAou5XhT1JMgpPR61uObQtwbtJ6ZDztAIseiA1V y+p1udr5z63d/0iOk+XhvAlTZ3f3iEJNrU7Keuj+28Nk/FEuR3vVcAIeTaNeSDmm416I sGP5KbG0PBiU5/PwcyT3bOf+dNeBkmtttlrCGBHspbMsLgREefYml3FWW4nMvuZe1gAe lyJMR8bSG9cUq/sB1DasroTuGcd4P6aG8NYGpiMmL0bgJL0jL8oFLvPWq9X5QuBfC4o3 VSILqDm77lQF5RgXr1sKPZC9ZxffJHeRLlIUBkLBsWfAeE3MtTfKNbPI2hbd+wDyM0eV EneQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si10397998edd.252.2020.06.25.01.20.04; Thu, 25 Jun 2020 01:20:27 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390601AbgFYIQx (ORCPT + 99 others); Thu, 25 Jun 2020 04:16:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:34438 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390456AbgFYIQx (ORCPT ); Thu, 25 Jun 2020 04:16:53 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7C008AEFC; Thu, 25 Jun 2020 08:16:51 +0000 (UTC) Date: Thu, 25 Jun 2020 10:16:50 +0200 From: Petr Mladek To: John Ogness Cc: Peter Zijlstra , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Paul McKenney , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: truncate dict: was: Re: [PATCH v3 3/3] printk: use the lockless ringbuffer Message-ID: <20200625081650.GE6156@alley> References: <20200618144919.9806-1-john.ogness@linutronix.de> <20200618144919.9806-4-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200618144919.9806-4-john.ogness@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2020-06-18 16:55:19, John Ogness wrote: > Replace the existing ringbuffer usage and implementation with > lockless ringbuffer usage. Even though the new ringbuffer does not > require locking, all existing locking is left in place. Therefore, > this change is purely replacing the underlining ringbuffer. > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -594,22 +473,26 @@ static u32 msg_used_size(u16 text_len, u16 dict_len, u32 *pad_len) > #define MAX_LOG_TAKE_PART 4 > static const char trunc_msg[] = ""; > > -static u32 truncate_msg(u16 *text_len, u16 *trunc_msg_len, > - u16 *dict_len, u32 *pad_len) > +static void truncate_msg(u16 *text_len, u16 *trunc_msg_len, u16 *dict_len) > { > /* > * The message should not take the whole buffer. Otherwise, it might > * get removed too soon. > */ > u32 max_text_len = log_buf_len / MAX_LOG_TAKE_PART; > + > if (*text_len > max_text_len) > *text_len = max_text_len; > - /* enable the warning message */ > + > + /* enable the warning message (if there is room) */ > *trunc_msg_len = strlen(trunc_msg); > + if (*text_len >= *trunc_msg_len) > + *text_len -= *trunc_msg_len; > + else > + *trunc_msg_len = 0; > + > /* disable the "dict" completely */ > *dict_len = 0; The dictionary does not longer need to be removed at this point. It is stored in a separate buffer. It is ignored by prb_reserve() when there is not enough space for it. > - /* compute the size again, count also the warning message */ > - return msg_used_size(*text_len + *trunc_msg_len, 0, pad_len); > } > > /* insert record into the buffer, discard old ones, update heads */ Best Regards, Petr PS: I am still in the middle of review of this patch. I decided to send the tree comments that I already have separately.