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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F281CC27C4F for ; Wed, 26 Jun 2024 14:28:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3AB816B0085; Wed, 26 Jun 2024 10:28:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 35B956B0088; Wed, 26 Jun 2024 10:28:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 223E86B0089; Wed, 26 Jun 2024 10:28:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 02DB96B0085 for ; Wed, 26 Jun 2024 10:28:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A56B14121F for ; Wed, 26 Jun 2024 14:28:14 +0000 (UTC) X-FDA: 82273269708.12.D95D2E7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id D1484C0013 for ; Wed, 26 Jun 2024 14:28:12 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XsbkZlkn; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719412077; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=f/HcaWei1+g0z5tguQtmN7bt92j3/7nt6PMTKiEI6IA=; b=VqXOhrKTm+Cf/DZ/BBlt5x6/gkmbIKD87i+AuWhClQYh52NA1UyCx0C/HPx02WKRgEA7ju rhjLmgB1v6GdRDv9J/lPe8H3wvKMWoo1yyuJC3nXOJhuUFdvNrn1vf8oz6cmAk4N5GBHCB jdiaQqvMGivWh+unSOO8ozQb4QKlh8M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719412077; a=rsa-sha256; cv=none; b=IzGUOvGexLtU2OCbufqtERvEJguU+KyRzCxhl4hkN3TIvXelRHn+Dw66aikk5lRnQkibDp uFJz+/IdtMBeEUG+VNf+ScJ/39rzx0N3r9AR0IUqjFb6ULDWldiSyUfob7U44wXxK4jCZd vc4htSUnTeP0y/HELPxk+ie2qTigzAc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XsbkZlkn; spf=pass (imf28.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719412092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f/HcaWei1+g0z5tguQtmN7bt92j3/7nt6PMTKiEI6IA=; b=XsbkZlknrMVQOKSfTt+IHSRwl4wCxTlW2TS4H7Jg1orB+/Plc4DgT8JopogFT1NGu63id8 UGTR69dH3890fSUxMUr7jyfCqr0bUHkHr5ufdlb3FjfZpKj5imak05x10BLnBg6tYdiGPx h59CF8Ar27kdu++l8BXkh0zNfPFN2lM= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-211-lj5JH7wMNvKQ7llts_K_jQ-1; Wed, 26 Jun 2024 10:28:06 -0400 X-MC-Unique: lj5JH7wMNvKQ7llts_K_jQ-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 79A9F1955EAB; Wed, 26 Jun 2024 14:28:04 +0000 (UTC) Received: from localhost (unknown [10.72.116.83]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7638E1956087; Wed, 26 Jun 2024 14:28:01 +0000 (UTC) Date: Wed, 26 Jun 2024 22:27:52 +0800 From: Baoquan He To: "Uladzislau Rezki (Sony)" Cc: linux-mm@kvack.org, Andrew Morton , LKML , Hailong Liu , Christoph Hellwig , Nick Bowler , Oleksiy Avramchenko Subject: Re: [PATCH] mm: vmalloc: Check if a hash-index is in cpu_possible_mask Message-ID: References: <20240626114324.87334-1-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240626114324.87334-1-urezki@gmail.com> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D1484C0013 X-Stat-Signature: 7j5crc53y3ojkeo6z68bdmayjmrfpqbr X-HE-Tag: 1719412092-588713 X-HE-Meta: U2FsdGVkX18s0BUC8G5cw8b56a46MGbQbwbYD/Qxhic5TIFGGeDcRywjlHmclJUXBYUE6VdmuiKPT5ydFiTIXBSnzJ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sFHuvkt0Hd7T8M3Mtepl+blsXth4alcZy7eKFMWSMaalXd1/LzO9x7MMYOqKqR44jcrCx8sJSxdsyiToPhEaDxGmBcIBo/LbPydqz4vF4lk7DAPswsLVRT1kLfsKVBSL6bem/UHqw+jBYmWH0psAxM6JPlfv3aCqbtxrcM9oR2QJDkZum6avFblDW9Uv2hsNj3nilcu6w4mIgttOXPxBKZz6m5GbYXu4y+R46nyjPpcxq7G2njdA/XJfxmgkP5h50HW0/37Cc60yz8iNYxH0N/XWI3DaQ2GOuBfPKCD4+aFHJgh4AIlXZ5/AX9NB7R0mLwCZobXxbw31hvZrW8oRBzzBQb0uA== 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: List-Subscribe: List-Unsubscribe: On 06/26/24 at 01:43pm, Uladzislau Rezki (Sony) wrote: > The problem is that there are systems where cpu_possible_mask > has gaps between set CPUs, for example SPARC. In this scenario > addr_to_vb_xa() hash function can return an index which accesses > to not-possible and not setup CPU area using per_cpu() macro. > > A per-cpu vmap_block_queue is also used as hash table assuming ~~~~~ > that incorrectly assumes the cpu_possible_mask has not gaps. ~~~~~~ Typo of duplicated word? Other than above nit, this looks good to me. Thanks. Reviewed-by: Baoquan He > > Fix it by adjusting an index to a next possible CPU. > > Fixes: 062eacf57ad9 ("mm: vmalloc: remove a global vmap_blocks xarray") > Reported-by: Nick Bowler > Closes: https://lore.kernel.org/linux-kernel/ZntjIE6msJbF8zTa@MiWiFi-R3L-srv/T/ > Signed-off-by: Uladzislau Rezki (Sony) > --- > mm/vmalloc.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index b4c42da9f3901..6b783baf12a14 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2544,7 +2544,15 @@ static DEFINE_PER_CPU(struct vmap_block_queue, vmap_block_queue); > static struct xarray * > addr_to_vb_xa(unsigned long addr) > { > - int index = (addr / VMAP_BLOCK_SIZE) % num_possible_cpus(); > + int index = (addr / VMAP_BLOCK_SIZE) % nr_cpu_ids; > + > + /* > + * Please note, nr_cpu_ids points on a highest set > + * possible bit, i.e. we never invoke cpumask_next() > + * if an index points on it which is nr_cpu_ids - 1. > + */ > + if (!cpu_possible(index)) > + index = cpumask_next(index, cpu_possible_mask); > > return &per_cpu(vmap_block_queue, index).vmap_blocks; > } > -- > 2.39.2 >