From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7941EC4742C for ; Tue, 3 Nov 2020 10:12:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 055CD206F8 for ; Tue, 3 Nov 2020 10:12:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="0kZJ8Rb9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 055CD206F8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8E9226B0068; Tue, 3 Nov 2020 05:12:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C2716B006C; Tue, 3 Nov 2020 05:12:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D93E6B006E; Tue, 3 Nov 2020 05:12:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id 4E4D46B0068 for ; Tue, 3 Nov 2020 05:12:15 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EC4DD1EF2 for ; Tue, 3 Nov 2020 10:12:14 +0000 (UTC) X-FDA: 77442691788.21.pie05_1a0eb52272b7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id C2F85180442C2 for ; Tue, 3 Nov 2020 10:12:14 +0000 (UTC) X-HE-Tag: pie05_1a0eb52272b7 X-Filterd-Recvd-Size: 5371 Received: from mail-il1-f196.google.com (mail-il1-f196.google.com [209.85.166.196]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Nov 2020 10:12:14 +0000 (UTC) Received: by mail-il1-f196.google.com with SMTP id g7so15601600ilr.12 for ; Tue, 03 Nov 2020 02:12:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b9Ktpm35fisVuHEhjhohgaqyboE8BmrrMoCITk9vnK8=; b=0kZJ8Rb9+0/H3MVDUevyCTWAc1pKYDKmZzYacQKCMmC/UQ66qmBgifq30qeC2iVztI ATPY1knKGSXDzJ6+Nm3tm3Ffn81WkUy/sBCmPfD94FibScrq8/Ui+9TUYldHJ7pcnk1t gx+nhhl2zwwSRNNGE6X3g+mK8ICIfWN15TzWFBAm2Ac+Fnp/Nc7mvMvQxol3TgeHLuHe fB2HlcDfVoQUKXEDUTDlyUi1MwQ1IJbHWYhRPhxFdctoJ/ps1THqNVawMwUkgd/uHgQv AYOBJizY9XV1L84dWspkXE7W+jTkhJPV/Ws9WaUAfWMNJujPYu+ExPkpZXByTNBy8wKU VaOg== 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; bh=b9Ktpm35fisVuHEhjhohgaqyboE8BmrrMoCITk9vnK8=; b=VKV5PMqSadMb2QU2VHEwj1jstbvyVB9oWqvct4I3U94+h/9sQvuVNUDrOpGrbqGATD rvvrikUMqoqlTAQPglgBGQ5HCrLrJFToGGl1zHV9LoJedH4ZzA7LzC8dvyXKPIRLJWMR jSFERAoUgXuW6V03pbLUJOBWNM24aKfgHvym7CPyTmE2fR8zmX9JPoiB5ZkxUqvHP/zp 8YLWiH8HAMqwTX+KisIuWK7dPixF7oh/Fn+DBt4Rprpq7QJMBj4Un6QiM17jLy5dkmbV csmk+qrI/BD+x1dHM2TCwWhn3nGeM1tw7Eo3ejPfUUwQKzfdSA4L8lc/fhFcEiDplTPb BQdg== X-Gm-Message-State: AOAM531I6vd74lzrQhBdVORXQVxkQfaekBZt9MRauw6a/IDbubKw6Fls jrjF1d+vP+XGqaHIfw10mTe/ZK2qfySxd3fh+NQnDQ== X-Google-Smtp-Source: ABdhPJxXaKRnidyqbx6iUG254lVJzvxaSAJ3Y8t7tBOtYCNJcNKDXTe4r/tIo6bcU8qIdoqImm6tntmYdwdU1LT5yRY= X-Received: by 2002:a05:6e02:926:: with SMTP id o6mr14285653ilt.287.1604398333472; Tue, 03 Nov 2020 02:12:13 -0800 (PST) MIME-Version: 1.0 References: <20201102152037.963-1-brgl@bgdev.pl> <21d80265fccfcb5d76851c84d1c2d88e0421ab85.camel@perches.com> In-Reply-To: <21d80265fccfcb5d76851c84d1c2d88e0421ab85.camel@perches.com> From: Bartosz Golaszewski Date: Tue, 3 Nov 2020 11:12:02 +0100 Message-ID: Subject: Re: [PATCH v2 0/8] slab: provide and use krealloc_array() To: Joe Perches Cc: Andy Shevchenko , Sumit Semwal , Gustavo Padovan , =?UTF-8?Q?Christian_K=C3=B6nig?= , Mauro Carvalho Chehab , Borislav Petkov , Tony Luck , James Morse , Robert Richter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Alexander Shishkin , Linus Walleij , "Michael S . Tsirkin" , Jason Wang , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Jaroslav Kysela , Takashi Iwai , Linux Media Mailing List , "open list:DRM PANEL DRIVERS" , linaro-mm-sig@lists.linaro.org, Linux Kernel Mailing List , linux-edac@vger.kernel.org, "open list:GPIO SUBSYSTEM" , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev , linux-mm@kvack.org, Linux-ALSA , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Nov 3, 2020 at 5:14 AM Joe Perches wrote: > > On Mon, 2020-11-02 at 16:20 +0100, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > Andy brought to my attention the fact that users allocating an array of > > equally sized elements should check if the size multiplication doesn't > > overflow. This is why we have helpers like kmalloc_array(). > > > > However we don't have krealloc_array() equivalent and there are many > > users who do their own multiplication when calling krealloc() for arrays. > > > > This series provides krealloc_array() and uses it in a couple places. > > My concern about this is a possible assumption that __GFP_ZERO will > work, and as far as I know, it will not. > Yeah so I had this concern for devm_krealloc() and even sent a patch that extended it to honor __GFP_ZERO before I noticed that regular krealloc() silently ignores __GFP_ZERO. I'm not sure if this is on purpose. Maybe we should either make krealloc() honor __GFP_ZERO or explicitly state in its documentation that it ignores it? This concern isn't really related to this patch as such - it's more of a general krealloc() inconsistency. Bartosz