Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1478469ybt; Thu, 2 Jul 2020 06:34:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIY0x8FquIz3oOGIgoUd47YcVJVjIQkPL98LNsS1aMOIOTo2+6G4tJy1dlIprWbiBy79O4 X-Received: by 2002:a17:906:f98e:: with SMTP id li14mr27546215ejb.174.1593696895733; Thu, 02 Jul 2020 06:34:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593696895; cv=none; d=google.com; s=arc-20160816; b=HiDoyM3vqgj0rMHyBJ4RMgms7TsjksafHFS3r0l8Fs1+OlCK0TFjItJcxV1dJ82dy7 AzpulonGvQismb26mXidzO7FPS74xNTMVqfjwN4XtB+4GrzX/MwcLBjXTFy3tW7fcnGw L2l6CVTTjp+piJRIbmpfaV8t1YkxZnHPZcnuxeXdJBPRkP6Qa0Yh02yzUKR8y8Zx8cco WCn+OCxmEUBkIZnPZSsFOSz2GQ98kzFsi0iBYfpXO7WFoaYvWpxuivE5AjCDcQPSfCVb ciyXqq3TVbk+yuCxJGSQdNnvyZGTbiMf573zwlzUfi5TeqfAd79L+30FOVu/nN5yq0BW /fBw== 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=c6EhhB5S3nti+ftS1nYbrf2T0yVNuQhHwYe/rigo+6I=; b=cpeXyfRCl7FcEUC+s7IzMTTQxlYaN6oMQw0VsqsJhtacgdesXEW94x5BN/vM9+ht9M zdFPS4dXW5BEFMJCZjrNGQcwbzAhubYx85WUv4SCwL/0YSLxW0ZTVi+2DahyFP4+f6tn LNUlX4DGCPn6QhvTvJeWKq9oV2ZaTBbUkbX9DW+JesT4Ov275tl+nk8g+paQOipdD/LZ P7drJujptMeyeeHSGLIPHSh2kQfXBf3Z+WMnX9yeSS+6f/jTHQbNQd4dRxoWCN2CEXa8 Q6yhLGoFQSf4WANCymKydDUqHEQb2wEYeABJWeRuu+f/k+rDnVb2I9voflk5f6q7Dpiu 9y+w== 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 dp4si7019585ejc.258.2020.07.02.06.34.31; Thu, 02 Jul 2020 06:34:55 -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 S1729199AbgGBNbv (ORCPT + 99 others); Thu, 2 Jul 2020 09:31:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:36804 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729047AbgGBNbv (ORCPT ); Thu, 2 Jul 2020 09:31:51 -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 6A47FBC6A; Thu, 2 Jul 2020 13:31:50 +0000 (UTC) Date: Thu, 2 Jul 2020 15:27:58 +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: Re: buffer allocation: was: [PATCH v3 3/3] printk: use the lockless ringbuffer Message-ID: <20200702132758.GD14288@alley> References: <20200618144919.9806-1-john.ogness@linutronix.de> <20200618144919.9806-4-john.ogness@linutronix.de> <20200625082838.GF6156@alley> <87sgeh3m5j.fsf@jogness.linutronix.de> <20200629140445.GK6156@alley> <87ftad8rh4.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ftad8rh4.fsf@jogness.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 Mon 2020-06-29 23:57:59, John Ogness wrote: > On 2020-06-29, Petr Mladek wrote: > >> @@ @@ void __init setup_log_buf(int early) > >> + prb_init(&printk_rb_dynamic, > >> + new_log_buf, order_base_2(new_log_buf_len), > >> + new_dict_buf, order_base_2(new_log_buf_len), > >> + new_descs, order_base_2(new_descs_count)); > > > > order_base_2() is safe. But the result might be tat some allocated > > space is not used. > > > > I would prefer to make sure that new_log_buf_len is rounded, e.g. > > by roundup_pow_of_two(), at the beginning of the function. Then we > > could use ilog2() here. > > new_log_buf_len can only be set within log_buf_len_update(), and it > is already doing exactly what you want: > > if (size) > size = roundup_pow_of_two(size); > if (size > log_buf_len) > new_log_buf_len = (unsigned long)size; I know. I though about repeating this in setup_log_bug() to make it error proof. But it is not really needed. I do not resist on it. > I can switch to ilog2() instead of the more conservative order_base_2(). Yes, please change it to ilog2(). Best Regards, Petr