Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3085286ybt; Mon, 29 Jun 2020 14:59:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrbY4cO51pBhelpe0fkb/2i6lqlu9gt6hg4+0bOih7XvWtyyy3m6QuvpLbWxJCMbt0MHNW X-Received: by 2002:a17:906:e089:: with SMTP id gh9mr15439015ejb.482.1593467972960; Mon, 29 Jun 2020 14:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593467972; cv=none; d=google.com; s=arc-20160816; b=QKtQI1afZgP5WUoyx+pxFSWIHZJ/EbE3ISC2+c2caihqfWFgRBNpYsDiLOucl2Hrw7 dfaCZeJIXNGyp2Z8UkWj9tW8c4drzwPHlACWOFULx6ARfTlG2iEzmHNQ+seXhr/jGIe8 xUzytVgLSa7l1LlqMrwYyClaIdchAFD8R42viWIRq3rTO1IrbFk3XwOhbbAocX0/xTuv GDhSOG26qdge1snISEnK2lPJ6/31BvK/c8Z64jLDvYnAVLaeeOMP1bWanA4BhAx3hdS8 eFq03n9YuAuBM9y8/+4LWRd1YRgKzrKgs/O89cTN7oxI4S2aQBpVYg4P+E3sHVihzzWt j2fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to:date :references:subject:cc:to:dkim-signature:dkim-signature:from; bh=qCfJAHafYa/AK9R1oGXdsMRC8dDD1+/B6dAzjfz2e8A=; b=RFOQNe4F4Lz/HejQ4sxBAeLicXoFcSTZ/L70LLbUFiloRU24u7BayGSik/QQ6WUFP+ g+H1Qf8LDAG9GY3F70lbOk/YV/xNiptHYr8usPTntUkqIelL139Q1syS4HyCz509vo0L urytwQdPWLwRXX0H871NS+MhbvJ19mkWe87F4nWlC53NlSIWBLtuBFp+a03RWuyfQWPB BXRM4osm9ImOvquPfskAPSP7CfcGjq7pBsOib26O2osUA5+mYxiHDTcEcy3XkkSZ0iNI ToXVmca43MOL9KIE/aRp1NBrGg/9FyvAUof/5YeyuB/dpGKreoGiMVtFvzJgBg58SGf3 3d2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=atALUCdR; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si636485ejn.10.2020.06.29.14.59.10; Mon, 29 Jun 2020 14:59:32 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=atALUCdR; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389772AbgF2V6H (ORCPT + 99 others); Mon, 29 Jun 2020 17:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728939AbgF2V6F (ORCPT ); Mon, 29 Jun 2020 17:58:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08FEDC061755 for ; Mon, 29 Jun 2020 14:58:05 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1593467881; h=from:from:reply-to:subject:subject: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=qCfJAHafYa/AK9R1oGXdsMRC8dDD1+/B6dAzjfz2e8A=; b=atALUCdRSCjttKOnEF7ACaejPFRnLCROGTU2TYcrTGB+x4/vvCK2w3z0nOYKLM29guozda v7GCs60PvZimi55BI+pF9yKr/oUNB2pfhzkq7fNd86NV8iVTuqfRYKSZwZexUdfeagQSsQ r1F6NS0luJXHyEo3nMPC7GqnxrpGXEVvOdhan1/v12ZxlCOJrLWrUEucsY22IFVjXWjuhM YrYO6Zgzj0fEHOiEM+CO2MkJKNZZmCoA+gIHSwB53Ee5SDqiG6MXljMOzzertMSSFJkEGB dyhtUpSOIV8vYMaows5UqYXNooA2Afc7Lu0+X+b8nSliReFAIoK1N09pDp8WnQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1593467881; h=from:from:reply-to:subject:subject: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=qCfJAHafYa/AK9R1oGXdsMRC8dDD1+/B6dAzjfz2e8A=; b=0UaMBvXKer7+fp5NEnvGteOT9ErcAAfKjSd3iwxofOplHufM1dhe3a4AYC6EWgF6qzN1Oq lry2ysi0HSt+ASBQ== To: Petr Mladek 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 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> Date: Mon, 29 Jun 2020 23:57:59 +0200 In-Reply-To: <20200629140445.GK6156@alley> (Petr Mladek's message of "Mon, 29 Jun 2020 16:04:45 +0200") Message-ID: <87ftad8rh4.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 can switch to ilog2() instead of the more conservative order_base_2(). John Ogness