Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1764491rdb; Mon, 9 Oct 2023 02:00:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcNZ6NF98jY2k0P+A9zoFn5/57cj56qCWH16aslp/eh6YuWZSSd558zADysCSuWVvkTskS X-Received: by 2002:a05:6a21:2724:b0:16b:74db:8fde with SMTP id rm36-20020a056a21272400b0016b74db8fdemr8752830pzb.61.1696842055251; Mon, 09 Oct 2023 02:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696842055; cv=none; d=google.com; s=arc-20160816; b=O1GsWVyv/EzrTeWGcKrDmJ7XPpyiKE5B44eGkn/7IZLt9BZBbeLeY3TOcIhXK21DhR 2VqY9ijfkUR8X8b31TM8RIi5o9SoVAUMx78y7QPjV7Pxt90/SDI2H6ZUM37yNhoxrqMg hDv1I4dIXT+Mg7CxX+YJKEAM/FC8SOUhkZ2fbARqzWNXs+/vTG188eueUavHYLt0K0+3 GR3Fb9B8Il+xWJvqrjWvV/fAnkP5fI1cx7Jeq2nTVfVRWv/ODVvY4GqNLTuLfY/YWaOy mrG3Dngzr29r5AcWsA152IzorZOWnjtljNOzVM/hRJoEbE7SuvFClRg1P6Pe7MHyC+LE cVVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8StrU8p4Asv0JzFS3HoyE3rwHET/Hez/P+/rBmMaFtk=; fh=D7uhrQnmQG6xf11gbvfi3iQ1A4p/6GZN4OQA8frEvwo=; b=mkZXOM63jlotQRFN90vAuOeJloCkv3qJWwGv0h6/N2XY55KemmyoiK4MqMDGrZJbs4 sfeWih2Ef84pEU9ChO+riBeZ3HpOPTNFpgo5gfwe3x3IEjSdBH3PUUZc8X8gGpWsJa7P Hq+pinic9sEXtOkBvGZHayFVFqA0wtY1AwAB2u93kNkA89vC8wTBIYSbOTykpLl+xoIl NurbWnWXgltE307Q+WmHehVJ5aNcpKmryMCF2xWMOLpGH0AoqC2Jn12jSZ/jcv9NBT6w cX+lk7VZ8ZRr3hx/RTGjldyPkiwohHTFu+OTU7prLzaExLo+MPKmRQmGTTyv9Vl/1jmy kQoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HR2vepmF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id eb4-20020a056a004c8400b00690f74dd2cesi5688760pfb.354.2023.10.09.02.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 02:00:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HR2vepmF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9F6AF80D2AFC; Mon, 9 Oct 2023 02:00:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345624AbjJIJAO (ORCPT + 99 others); Mon, 9 Oct 2023 05:00:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345584AbjJIJAM (ORCPT ); Mon, 9 Oct 2023 05:00:12 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BDBDAB for ; Mon, 9 Oct 2023 02:00:11 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-65afac36b2cso22898856d6.3 for ; Mon, 09 Oct 2023 02:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696842010; x=1697446810; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8StrU8p4Asv0JzFS3HoyE3rwHET/Hez/P+/rBmMaFtk=; b=HR2vepmFD6lJcBqveS3vZOoo7Mf7CD7SZq1owXB+P7rx/9dUymZMIB/LL0rTTvbnBc cYEoxXQ080p17y8Axp9P6NnEJvdFs4CvbpYHyGVooV6U2bnSNq2CbfEpEREpeZK/1Vvi 3j3hCGcEBhWrCwZMX0Hc1MYH4DPb72QBnONgK2IaGvCl02fCE9sYvnbbJAgefZKUOZwF ZlMd3X7G6dt7LIQt66OV9wy0K23EqW+yO5eafZbSwKm7tPXVruCh7zNZVLwnQePeg+k4 A0PHVcS+qnew09ALXAIR/GAE+y92UljQL1BKApZ2K6X0+OQFPT+QqjJwTir6mkddGxUT bGOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696842010; x=1697446810; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8StrU8p4Asv0JzFS3HoyE3rwHET/Hez/P+/rBmMaFtk=; b=k+V9IPNWGDXuK3hNZT/C753KAMBK/CDHkdm6hXRCCJuWgZxKVqWUdHyfmkArJDB504 D/pvNCJeKVq8vbvlZhgmDSdyqTX7SEUBuzoGIw8PoQRLnZDx16gxBXrOlfowQmAtnj1/ Ovn+EhWlKNT/Dfw68OM3rPJZJe6rYyG5iwHZaVlMvuFRtqH4r7GJ+kUY7mlJfrNbnlrr /+eE+xUlsRCsptc0A4zjQjU7q+GMjWH/8t+Vjfk41v40vgbnmXPOLi7PRP+549D28une pcYsgXar9PkQYXwy6gXOFfceulLsE94hBsYNzIS0RHemfj4dCu91UbQx+qn/57i56S9C pJmg== X-Gm-Message-State: AOJu0Yy8MRLU4Ke/OEJyjM6hkwegWY8AeWPpmQDaYY7eeYeuOY2SU/Lb d/opzl7I3G5qS1FVH8fPaYKG+S/JRkJvdeuVfToLfQ== X-Received: by 2002:ad4:4450:0:b0:65d:56c:5177 with SMTP id l16-20020ad44450000000b0065d056c5177mr13158908qvt.57.1696842010047; Mon, 09 Oct 2023 02:00:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Alexander Potapenko Date: Mon, 9 Oct 2023 10:59:30 +0200 Message-ID: Subject: Re: [PATCH v2 07/19] lib/stackdepot: rework helpers for depot_alloc_stack To: andrey.konovalov@linux.dev Cc: Marco Elver , Andrey Konovalov , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Oscar Salvador , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 02:00:50 -0700 (PDT) On Wed, Sep 13, 2023 at 7:15=E2=80=AFPM wrote: > > From: Andrey Konovalov > > Split code in depot_alloc_stack and depot_init_pool into 3 functions: > > 1. depot_keep_next_pool that keeps preallocated memory for the next pool > if required. > > 2. depot_update_pools that moves on to the next pool if there's no space > left in the current pool, uses preallocated memory for the new current > pool if required, and calls depot_keep_next_pool otherwise. > > 3. depot_alloc_stack that calls depot_update_pools and then allocates > a stack record as before. > > This makes it somewhat easier to follow the logic of depot_alloc_stack > and also serves as a preparation for implementing the eviction of stack > records from the stack depot. > > Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko > +static void depot_keep_next_pool(void **prealloc) > { > /* > - * If the next pool is already initialized or the maximum number = of > + * If the next pool is already saved or the maximum number of > * pools is reached, do not use the preallocated memory. > */ > if (!next_pool_required) It's not mentioned at the top of the file that next_pool_required is protected by pool_lock, but it is, correct? Can you please update the comment to reflect that? > + > + /* > + * At this point, either the next pool is kept or the maximum > + * number of pools is reached. In either case, take note that > + * keeping another pool is not required. > + * smp_store_release pairs with smp_load_acquire in stack_depot_s= ave. As I wrote in the other patch review, I think we'd better keep parentheses at the end of the function names in the comments (unless there's a style guide telling us not to).