Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2860160imc; Wed, 13 Mar 2019 03:11:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvCMj/th3Dza0G7exWvZYEQZZulaoAs9EnKDLth/RhbYFPbaoJ+OBkus7jvN+gyaHY3LCU X-Received: by 2002:a17:902:bb90:: with SMTP id m16mr46174398pls.49.1552471917879; Wed, 13 Mar 2019 03:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552471917; cv=none; d=google.com; s=arc-20160816; b=xHEs69XthDMwliVsOk6pX2pqpMATVD/o3O6lop3FnJpM4Am4xaencIOAf9/cZ8uqIc mumTurGG1eSmPU9aouHGMpVt1f8GCrUZl/0TTZUN3uFZIUR/Ye32y/ZubxsYURklZWAE OlPfzj/QcHMmsGig3RsZ7s7HNn96w9BZxKogeNUcEkSephegBHhtx7tHJpGaB4LsMVjQ zjSxoVvOykI48ZXqjtl0ozyEqZvZjxSlxFjOmY/3UtPayTdNS5LRbHlXXv9FrZZowMPJ LV5J1cX5++SOqI08w8dEv71j/OY8JcaHBGrrYsnZJyOYlljB2JySfRUWy6qAYprTi1O3 1DFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=gmZMR2FgJtLOlv2sUTveWppNYBRDzUQBA95KTOMoDMo=; b=RF5pu9+JIhWM/xmyPC5kzaW97c86VxBf/aHgQWnHJz0gL2MvLGOyUAufnfRI8fG3jd olvgVvFNNyHCyf6mU7XhynNMMGPv6JLgzcEgtp8Bl6Ig4UNCsLqlFDUnKMWbteiXb1TI GpLABF7r26/H8cuxLXFuh56i8yX6Z6Rup6vtpk3DuZRi4FIUXGpmuxWSlbZpK2sAJ+WR koFBpljZ9bjmaOz43ZI8y0W7tlWvUW+ERv3LDlqkBY4Qsrlzw0HRCqB3ycXMdQWnEpGN loCwKu75EN3dD1kpRmqrDm05GSKtXvXT4aNI/CloX7R42IwZz8euGyAvZdJaaBuLcDzu d7zQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h127si10746096pfb.213.2019.03.13.03.11.41; Wed, 13 Mar 2019 03:11:57 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbfCMKLV convert rfc822-to-8bit (ORCPT + 99 others); Wed, 13 Mar 2019 06:11:21 -0400 Received: from mail-ua1-f65.google.com ([209.85.222.65]:46719 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725856AbfCMKLV (ORCPT ); Wed, 13 Mar 2019 06:11:21 -0400 Received: by mail-ua1-f65.google.com with SMTP id j8so441232uae.13 for ; Wed, 13 Mar 2019 03:11:20 -0700 (PDT) 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:content-transfer-encoding; bh=w6c/sy5kIHwpmb/ad29lLtozgPvilF5ILnjRBOcqq6Y=; b=Y9QT/R4t87bBXxfGR2Adkm8ujh5ht9t1Ymc37fpebw37d6W7HlgMvV6dKwATiHD4mH V/AFgokA03dW6c7LAQQAn9ECgdQHIVextQhooZTUKEJttH7N0Ythu9bNjWBRcLpxXxgz nwclFJWdhNiQhvjs4g1H0YGbp72Up1Dr/hcp7vTjFJxOu7iSIaaoTgTlObU77fgOcVen qI2F9ww9w8JgXxXwr1352giNneCIP8MJcCIAIoDqcoLKBZpaXf5L/cGMJQQFSZf+NfpC m1qnTMRsy4dFcM3U/Q7kH+ZNCCHfVFOoluhBO8CjwOGtYp4Jna5cis6iDvHh6re6J4F+ mNYg== X-Gm-Message-State: APjAAAV0fb5AkVtl8L+0mwAzpI8gDWjI06km9hlFaeY8F+NjskIbWN3r ETZGx6XgGjjR3scTNKQ79MDuMNRssrQO4lBS5YBsERc7 X-Received: by 2002:ab0:7191:: with SMTP id l17mr21062310uao.28.1552471880343; Wed, 13 Mar 2019 03:11:20 -0700 (PDT) MIME-Version: 1.0 References: <20190312133047.16201-1-brgl@bgdev.pl> <56704758-ee74-0e9b-de1c-1dc94deda8d7@cambridgegreys.com> In-Reply-To: From: Geert Uytterhoeven Date: Wed, 13 Mar 2019 11:11:08 +0100 Message-ID: Subject: Re: [PATCH] um: remove uses of variable length arrays To: Bartosz Golaszewski Cc: Anton Ivanov , Jeff Dike , Richard Weinberger , Bartosz Golaszewski , linux-um@lists.infradead.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bartosz, On Wed, Mar 13, 2019 at 10:50 AM Bartosz Golaszewski wrote: > śr., 13 mar 2019 o 10:45 Anton Ivanov > napisał(a): > > PID can be more than 5 digits nowdays. > > Do we have a macro in the kernel that yields the minimum size of an > array to fit a number? I can't find it. I vagely remember seeing > something like this in systemd tree. If it doesn't exist in the kernel > then maybe we should copy it over. 1 + const_ilog2(n) / log2(10) = 1 + const_ilog2(n) / 3.321928 Using fixed point calculations, that can be approximated as 1 + 19728 * const_ilog2(n) >> 16 1 + 77 * const_ilog2(n) >> 8 (the factors might be one off) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds