Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp632131pxb; Thu, 12 Nov 2020 12:13:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwltWbhdLRezSRzJlLFw8btpNdXsDpPC5VXeo+iF1gH9cOuQ77t3wT6HEqyelbQUvrhYfiR X-Received: by 2002:aa7:c44a:: with SMTP id n10mr1705384edr.145.1605212015711; Thu, 12 Nov 2020 12:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605212015; cv=none; d=google.com; s=arc-20160816; b=k6D8xQur+JyQGD4XMOL+3+zOoW0he3pcPsuBQtKA1kEI3BS3pmQ8ugryA9OcMEG/94 iP538jwHP9vK0wyM08cDfKNteYRdFdpRAZpxETIDLCwBiRFL4DOC/7DsjacV4dOzOp4B /8TeKlpuY6DIF7cYhwPuNLE7cX6sDu3aM2YcYvVgNU/bv4p0/F9YFKMw6dctwTADqky5 YazUrc1JvKVpQFSGkPgy73/nCaD6/9VJP4DHeCxj7l2Y5CnX8kT6ireu3WxXRUpuiYe0 4ODTnN8n/oPZrBJzScTfVmq3ej4uxvu272HKOLxr2YplKDjWPUoHPGD2+T2pW3hyNuHA 7WNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2S2n4Y93UoJG9nL/klprM8z9XQcvbrv6CcFxLYZgtjg=; b=TkGFcdi0VfffI35HS+16m27SCxlcAR1rDSqonWBOTgQYrhqGrkW7MRavO7WPd0rdED EPXMleoWWuWtrQ/7TVbgljlQ10UZYx2ckbSAfssZ/42OzF1dkzJ17o+HePP1E0ABlNYD 9JeQB9TuBvRJ2fDUpITENa3iGOAfFGSvUX4m3UtN9Dv84r1htEeJBxCD0QuRHGpTprqR 8Hopgw3a54qLhSfarQe/gaZoY14c5BqDAvo9KADX0B3cav5lszx1ynOIMiS30W5Rq0dD nOgZNNBO5hzHfC7UbdT+eydh8FxaTf/iJaHqOgHzf97M6En7uHFAzDCrpQHMaLLtvQ9H voqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RNW8PZ9+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si4117278eje.564.2020.11.12.12.13.13; Thu, 12 Nov 2020 12:13:35 -0800 (PST) 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=@google.com header.s=20161025 header.b=RNW8PZ9+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727011AbgKLUL5 (ORCPT + 99 others); Thu, 12 Nov 2020 15:11:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726930AbgKLUL4 (ORCPT ); Thu, 12 Nov 2020 15:11:56 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0476C0613D1 for ; Thu, 12 Nov 2020 12:11:55 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id w11so3366836pll.8 for ; Thu, 12 Nov 2020 12:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2S2n4Y93UoJG9nL/klprM8z9XQcvbrv6CcFxLYZgtjg=; b=RNW8PZ9+tID0QSbR+rpTOcvI3kI7ebx4DXx6gAvjzcH3TLPaxKEz9At/oTpE9K3eWk zLQYhMMGcOz5YFxKA8FTnfipVDwDqCSZ/1QeqvUxu5ccf+qWzPAZSyWb68SjN3RR3wDF yyfJxNDonQnDg/+1fR5dfNMdh+RhSEexdb2rj3NJGdrmrqCelZde4KfnMZ2li6NUouwM k2wI0oK6L4GvBGymy315Vdo9dJqgnzWCOy47TCt3j+uFCcJUoDFeFLigu9N0vm8TR+Bz Oq9sGnU+Q4Hm6eQUbUcOL7tNrMQwydrYcSNUfuWs/v7i6OelIwjhENz9qIKbXUQOh2Rs p7+w== 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=2S2n4Y93UoJG9nL/klprM8z9XQcvbrv6CcFxLYZgtjg=; b=OJ5W2T3N35rJrG9qqqxes3lqdea6q3wtcIfZh8bq7xZ2NfimR2i2TyT/3XXpZcCChj h+bDwd6QvQ1g54/HVTQhE2DKT0TKAAxIiCGcOlY61mdWdvGJtAdPHFssrtZyxv8b5nY6 VbADwYwxEMnaJ5H3H9eRQoQaGK44ch4veF7KUEpVxV5Yh7v6kin+pXXO8f71TneOxAzQ LbMtuyiuYsvsQzkRl/8cHJ3hjdO6tRlu/r0qSlflXXgs9aFovcrYBr0fwSFAQfpAGeBb BoSMe4hJwjI3UUba17FZRgkOL4mjf5RoVD1JNydELLbyXqW81lDk9PSK7b+JvZUvRi/D SX8A== X-Gm-Message-State: AOAM531T7/Mo60u7/wfmVMzHT0Lea9PGTlnSulpFFzzEksT6jurpemoT guNpmLaIxgnw/nLF+bp7YL8MkVJtdO9X0p47SWyGLQ== X-Received: by 2002:a17:902:d90d:b029:d6:ecf9:c1dd with SMTP id c13-20020a170902d90db02900d6ecf9c1ddmr902814plz.13.1605211915059; Thu, 12 Nov 2020 12:11:55 -0800 (PST) MIME-Version: 1.0 References: <20201111230601.GA984367@elver.google.com> In-Reply-To: <20201111230601.GA984367@elver.google.com> From: Andrey Konovalov Date: Thu, 12 Nov 2020 21:11:43 +0100 Message-ID: Subject: Re: [PATCH v2 18/20] kasan: clean up metadata allocation and usage To: Marco Elver Cc: Dmitry Vyukov , Alexander Potapenko , Catalin Marinas , Will Deacon , Vincenzo Frascino , Evgenii Stepanov , Andrey Ryabinin , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev , Linux ARM , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 12, 2020 at 12:06 AM Marco Elver wrote: > > > + /* Limit it with KMALLOC_MAX_SIZE (relevant for SLAB only). */ > > + if (optimal_size > KMALLOC_MAX_SIZE) > > + optimal_size = KMALLOC_MAX_SIZE; > > + /* Use optimal size if the size with added metas is not large enough. */ > > Uses the optimal size if it's not "too large" rather than "not large > enough", right? Not really. If the redzone composed from metas is begger than optimal redzone - we're good. If it's not large enough to reach optimal redzone - we need to make it bigger. > As it is worded now makes me think this is a fallback, > whereas ideally it's the common case, right? It's hard to say which case is more common, as optimal redzone size varies and depends on the object size. [...] Will fix the rest of the comments, thanks!