Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2755315rwo; Thu, 3 Aug 2023 14:35:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyvxz+neXmS110fQjgVgfFL/g8AM3tapvA+a4mHvr4iq/Zo0w/+U7SWCzJ3/pmL8y72n+L X-Received: by 2002:aa7:d0c3:0:b0:521:d1f0:3013 with SMTP id u3-20020aa7d0c3000000b00521d1f03013mr15096edo.33.1691098547938; Thu, 03 Aug 2023 14:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691098547; cv=none; d=google.com; s=arc-20160816; b=JQnyw3aT5Vq5QkLORyj8oag9+Yym02IgIN1+kgXTUBWKFfWnkhYbxa9tLMbuBcnu2C CGn4RLt77stiT7y3cEwvBD6GbOvTHh3amfNPDL8Jc0DQFAkojmgOD9zX5W/kvG2rAvat 8TLCpAuggGLRMy3NuSkoBOMukUGDv5Ee/0WVbalZcOKNh2Mbi4Ro9952J8epChzHZy1X XguES0Z3hD4ONIsvQhyDjj9fr9Hu6yko1pobAVIFeA5TP73fLN4nvuB5QSChl1LGCJFT J9P61VuZG3DNmIeHpwMX0XH0ZWiDSCtr0inVxS6RlkDSuesrSKiG9i239iIp9Dd7KCsr HyJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QuYitPJZqMO1br4FQSyqi//ppdhPI+NAR1KWcWA6710=; fh=UGFg5P8HKG8uEkywjW500Pb2J9adYjwoBSntkBRdmI4=; b=xbYhJSkG6TWSeyYU8uWOuctKC7xJXwFq8ZbF1Gs6G2cOR5kvW2HBqO6f54DFoabi7N bLqtZk/1b4NFwdnfZhxGfLdfl/bBgsG2QBTUd3bGG1DMQWJ74rfINy8jpUbQZ5Kd0FQu RkFscR9AhCXQWI1U/in7X3j98xUdIyOZ9ujTY2EeYpMab9SS3djoYs2TkNhLBJEbMuy9 XABsgWSJH89QmrLwZHVfhLmGGe/wV2UFlQ6cfspuIBhTQNZSi0YJWZ/Xo1jGu/KWQSEh +L1E3x0iqT8NGwIE9TgOCEHFoAqy2uzAiadPZ28O4nNW7YJoN+ZCA9xx6i9UglGP+3/D NnPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gs0xR52Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t17-20020aa7d711000000b00521db0bc984si481274edq.121.2023.08.03.14.35.24; Thu, 03 Aug 2023 14:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gs0xR52Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230521AbjHCVAc (ORCPT + 99 others); Thu, 3 Aug 2023 17:00:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbjHCVAa (ORCPT ); Thu, 3 Aug 2023 17:00:30 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D9B1AB for ; Thu, 3 Aug 2023 14:00:29 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-40fc654bea1so9904641cf.2 for ; Thu, 03 Aug 2023 14:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691096428; x=1691701228; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=QuYitPJZqMO1br4FQSyqi//ppdhPI+NAR1KWcWA6710=; b=gs0xR52ZjdCvuFTwrpGe2Hferm5v3XQEZVvpsyDiKFWkASHv9XT1wstoTnEmVPTceU HIvA62wJaNYL4R5ZVKOPdmg1/irCFyXEeyWNdqwji2wYZkkeLuMVyk7Sk3nsu56Znp3a 1QOBVdF3FH0vXdnA9Qvoq4KSR0DruXQOmV0X55BFmsZrINuvbqHmlmKCGPAcuj6H44fG JmsY0Se94Ure36WyDpTVwGNfaWQuaKLEG3h5QfhG7wtk6nNZ7VWfxpT4bZu/iftNyE9l 52LX89W4PvME1n4Y9o0NusD5zJBO/aTRZL4P7sBEkNUx2LPojjb9/juXBxvHnYAyGHxQ zi3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691096428; x=1691701228; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QuYitPJZqMO1br4FQSyqi//ppdhPI+NAR1KWcWA6710=; b=QOfS9CC6yV3R+OCEDYP7fscvj/fe4Q9kXohb7cQTr27ewa6ZO+PuFVgFidozOwDzQe QtJwkkClyrF66gSamLhuRWGi3z/9j06FNTDAEhdYNmkACn18zXESEpclMQK8Dx8Dt690 VO8PZil4xYGnyq1k1mFA9hf0SlbKPs0ykOzyRLA016h0yKAPFY2dQUYjfQd7RdR1G2YT 6kzZkk3d0en4sNAYudjd2gC7S4bDKhBGYgwad/vTupD2/ASOkMj0Cfl1VpSTN8GjGLIN ICJ+vyaMCTxnWjDdh34BfseR31BCOd7CI0YsWmkRMCopVuBI+YPJcRVJIE91X0YBUkxd 08Tg== X-Gm-Message-State: ABy/qLb+4Cz9ucjvkSYpzGJivb6z64C+KX6MPgDOl68FqqnPc7CXIPcz HH0DyK2QFHjq1qEGrtTmRdHOFhj5mJ8= X-Received: by 2002:ac8:7d90:0:b0:403:eb3c:1fed with SMTP id c16-20020ac87d90000000b00403eb3c1fedmr24878626qtd.35.1691096428036; Thu, 03 Aug 2023 14:00:28 -0700 (PDT) Received: from localhost ([50.217.79.158]) by smtp.gmail.com with ESMTPSA id e21-20020ac85995000000b003fde3d63d22sm189653qte.69.2023.08.03.14.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 14:00:27 -0700 (PDT) Date: Thu, 3 Aug 2023 14:00:26 -0700 From: Yury Norov To: Peter Zijlstra Cc: andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, Andrew Morton , Linus Torvalds , Mateusz Guzik , linux-kernel@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, rppt@kernel.org Subject: Re: [PATCH v2 2/2] mm,nodemask: Use nr_node_ids Message-ID: References: <20230802112458.230221601@infradead.org> <20230802112525.633758009@infradead.org> <20230802193616.GC231007@hirez.programming.kicks-ass.net> <20230803084125.GE212435@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Consider MAX_NUMNODES == 64 and nr_node_ids == 4. Then > small_nodemask_bits == 64. > > The nodes_full() will set all 64 bits: > > #define nodes_full(nodemask) __nodes_full(&(nodemask), small_nodemask_bits) > static inline bool __nodes_full(const nodemask_t *srcp, unsigned int nbits) > { > return bitmap_full(srcp->bits, nbits); > } Damn, copied the wrong function. This should be nodes_setall() of course: #define nodes_setall(dst) __nodes_setall(&(dst), large_nodemask_bits) static inline void __nodes_setall(nodemask_t *dstp, unsigned int nbits) { bitmap_fill(dstp->bits, nbits); } > And the following nodes_weight() will return 64: > > #define nodes_weight(nodemask) __nodes_weight(&(nodemask), small_nodemask_bits) > static inline int __nodes_weight(const nodemask_t *srcp, unsigned int nbits) > { > return bitmap_weight(srcp->bits, nbits); > } > > Which is definitely wrong because there's 4 nodes at max. To solve > this problem, both cpumask and nodemask implementations share the same > rule: all bits beyond nr_{node,cpumask}_bits must be always cleared. > > See how cpumask_setall() implements that: > > static inline void cpumask_setall(struct cpumask *dstp) > { > // Make sure we don't break the optimization > if (small_const_nbits(small_cpumask_bits)) { > cpumask_bits(dstp)[0] = BITMAP_LAST_WORD_MASK(nr_cpumask_bits); > return; > } > > // Pass the exact (runtime) number of bits > bitmap_fill(cpumask_bits(dstp), nr_cpumask_bits); > } > > Hope that makes sense. > > Thanks, > Yury