Received: by 2002:a05:7208:13c3:b0:82:bbfa:f723 with SMTP id r3csp1134734rbe; Tue, 14 May 2024 12:35:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLtuw/R7YUk4L5aMkyoV1CAZtNbXJ2HcZ+gDlskpN16YrTX/ub6Wl/IGyB+818ArzuB8afiZYhcfVAvQj7R9SiOUPWrnt4MrdBvdq8Og== X-Google-Smtp-Source: AGHT+IFBooGu6V7hOFtb9bknYbg3yUIjBWPN77fUm+18L9dGvT9myLpShZUDaMcr3tqmn2Hns9IG X-Received: by 2002:a17:903:2443:b0:1ec:b6e2:da8f with SMTP id d9443c01a7336-1eefa03a440mr257070445ad.12.1715715309342; Tue, 14 May 2024 12:35:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715715309; cv=pass; d=google.com; s=arc-20160816; b=Mca+cWUFI2sAX/n6VtEGWAEEBDj9MUkt9ZDB/mdTdij0dzmdpnEjAHL3mDaaEYF1hU iU1fWLY2BJt+GVvxzO45cJ6RSnNh2e6kzrBJn5zbG9+56nmlv7UIdxHPJlaAmzu4t/x0 0h7QJHUYxK2ahPpQoSJ45SbNYWXSlSKxcjUu0AD5T942smYTC400+UH5ywjM/crr0H61 BYceuoznxzNAB34FQ1MXbMkwEWhlJnJiht7s9D4e/0St8WcCRYyze2Zb8rR32Wqjl2H6 /tiJwMMZbCn/kLYuc/JZEF5C2vbcvmKLY2Mctnb1WfOQ+oJkRXIBx23jl4Ndgi/BzzF8 4QWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=xdjUYMnYvtY8h5Wj9gD6r7f+eAOL0wr4zZKtPEpcVmo=; fh=oZi5eKU0QjNjqhVy+lIrjjGGjaz7VxxV59RKsfbjyYw=; b=HpsXjkMd3h3d9OlyOyFZLJMCDobSDi98UwD4i0gFwf1jyn1QJn/A4O3YG4jl3YesHr O+3ogJhs/9SmzJsV56r5T3ywHQho+bwZLpH+4endsX8Jz9pwS2Fn6GYvBJ6HVOQchbG0 +CEoTJbaxRtdNcjjQPBBV1cUoK+pKPn7czk8mUCZR9NIZelFXJrRS0qqFpSXh3x4S9JV XRTVRLztYqTnkqPVdo2dt/HfDz6dwQ29LpVMZm3epTIznCvSfbOcJRvilih5Oq198DSY WIKMml+bl+wn3Tz2BHD+actoHVqEENuglaWQ7nVTz3OBGz4AqU4xnNx9zgztnU66duhO sT6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DfV27Ypb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179100-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c26a435si122453935ad.612.2024.05.14.12.35.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 12:35:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179100-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DfV27Ypb; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-179100-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179100-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 090F1B21100 for ; Tue, 14 May 2024 19:31:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A01E181316; Tue, 14 May 2024 19:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DfV27Ypb" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39D76144D0B for ; Tue, 14 May 2024 19:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715715102; cv=none; b=ktO8DVUdiJ4X7+vyRWMftXsiLp5bFcfbsrDhCWAjB+1PWyhHHkCimE196NPlmCuB4tgpEk/M6KkPugrz0m4SWNROAbcVX2SasXGVBaoqcBiLtGe7DkmNMrHfoVNQfSYpQ5tuXhq03TQrWAD+EHbEYdF7yOTLzKj3+6wyYzDjKiU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715715102; c=relaxed/simple; bh=Se3Ij8G283o4D8/qcripghOev92UNfpmzpuWpKYRLZ0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=JoIF0axpthh6pErWonmKViFOIT1vN0gVoyo/2fXamdbN1yNw6nhYt5l2Pel5UeJ60Jh8Wq8K9MjCJX77jAhasA0zB3fiXLynuRxZ0pxZ7TMk1mI68JPOAeVVbYm7OzBcwoSmQcjW7YIrI579nzebBWFG9Hq4R5w+QIZuw0Ba++U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DfV27Ypb; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56FDBC2BD10; Tue, 14 May 2024 19:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715715101; bh=Se3Ij8G283o4D8/qcripghOev92UNfpmzpuWpKYRLZ0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=DfV27Ypb9DUvKPmZ1am0CxQXDO+ouVeL4LJZgUYe35yJPaFRkBqmI5HGhUiUkGIp2 urZIW/6Hx1MHSOG9mF7TIWBpMaCVwfab/uUZZrdidwMqzJTbIopXD9/LNs7bEpS2M6 aceqBh5tXX79S+7rMaEQ2EuxSPz1VR+N230Of4BmNUBRMVELVeLgchHn5nsBWKqgqR oVYDu3KUvODgxvR83K9SK/olDocN/FyKkuiFwoXguQvjVPxXE2tOrozgpT/lO2UqKo YDSy0QwJbyejnaH4W02iFtelUOu9vl73PWhmYHqvSuALLfB/xyrHymtDRHKI0fhrEM psIL73cdwNqBw== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Alexandre Ghiti Cc: Albert Ou , David Hildenbrand , Palmer Dabbelt , Paul Walmsley , linux-riscv@lists.infradead.org, =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , Andrew Bresticker , Chethan Seshadri , Lorenzo Stoakes , Oscar Salvador , Santosh Mamila , Sivakumar Munnangi , Sunil V L , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v2 4/8] riscv: mm: Add memory hotplugging support In-Reply-To: References: <20240514140446.538622-1-bjorn@kernel.org> <20240514140446.538622-5-bjorn@kernel.org> Date: Tue, 14 May 2024 21:31:38 +0200 Message-ID: <87eda442cl.fsf@all.your.base.are.belong.to.us> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Alexandre Ghiti writes: > On Tue, May 14, 2024 at 4:05=E2=80=AFPM Bj=C3=B6rn T=C3=B6pel wrote: >> +int __ref arch_add_memory(int nid, u64 start, u64 size, struct mhp_para= ms *params) >> +{ >> + int ret; >> + >> + create_linear_mapping_range(start, start + size, 0, ¶ms->pgp= rot); >> + flush_tlb_all(); >> + ret =3D __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT= , params); >> + if (ret) { >> + remove_linear_mapping(start, size); >> + return ret; >> + } >> + > > You need to flush the TLB here too since __add_pages() populates the > page table with the new vmemmap mapping (only because riscv allows to > cache invalid entries, I'll adapt this in my next version of Svvptc > support). > >> + max_pfn =3D PFN_UP(start + size); >> + max_low_pfn =3D max_pfn; >> + return 0; >> +} >> + >> +void __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *= altmap) >> +{ >> + __remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT, altmap); >> + remove_linear_mapping(start, size); > > You need to flush the TLB here too. I'll address all of the above in the next version. Thanks for reviewing the series! Bj=C3=B6rn