Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1406302lqt; Wed, 20 Mar 2024 03:05:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXu0TxH/KIMf0a2LhIGCFWOKUzy3Q/HmWPuLy4R83gOPV1qhLVVv2Aq1JyFl75l6iSSr+ArnmPaV30ZZlC5XpLLunqXk/KUgFs2EXQ9Ig== X-Google-Smtp-Source: AGHT+IEMURszuIyNubyOLhSdEuBlZQoGPH0jWW3QvqbaeQvzZMblwiSnEGL8m3T5Jp3QV77nTF8U X-Received: by 2002:a05:6402:1cc4:b0:56b:902e:b144 with SMTP id ds4-20020a0564021cc400b0056b902eb144mr4012275edb.12.1710929133385; Wed, 20 Mar 2024 03:05:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710929133; cv=pass; d=google.com; s=arc-20160816; b=STPw9otAFQK4zUl+eOxvyN1JibFbvPQ6O4+e4t2SN3vkOcUyhOcUyTZxSucUIS9BOY pVf+moYlN7/niygkZm827VnaRGqqO2eHUem24ObsJAQ+uYnCn3DgyJvytMgpsW7KNB5E KCJVDGhA0AXIQtA53F+WU2AcuUSFUr7L5IShlr0jD43kqCjiBn74iA6HVK38dANjjYqR 3/GK915Glp4iO1C1qB8F2OYHfzh0B19K2qcgWE2JGjXMkR1Fx10Azkw7cb6bSqBEMs/8 i/r/Lb/M8w3dQ7JLHGYbrJx94Xdo5MkT2xh0h/bGdHwas9coQFiheOENYweEZ793sW2U H87w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=VIZ0ATeO8q/WMl7Af2C8a25lhQGxqN2RZQIjxOdVzdI=; fh=29kF3k1G5XnfnvBx80C0WmNjEVW4PA3+/HN+wTUqsak=; b=i1B5wFDr5TO/2I1OQsV6mCZEJidYEgXfexqf0ZTqwd8HZ5j+y+g8kfBvdyEmOh4Oqy TNidHQCn2PcWOE/i8b66HljjorK5gFrYGMnu2MuKOv45fobWfJdhx/Uk7Se+zbkEtqmH IPiAgToitM7KTojXpeF6pyvDeLXHltamvteT9SQxTRoeVfVE8POjGRC5cjk9CoMKeLEV wi1srooYIlPPyP8RF/yFBQxjNKoPJAOkqPbQNEqY09NZwRRFDoak5nvniw2q+qXLnLlB kC4CTctwI92kmnIZU2d8LFcLWyB/EQgAIRpxySHa+VMx2+8FaOe9tQ4JgsLNgGa33GIy m13g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=k8CTDhkj; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=k8CTDhkj; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-108728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108728-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id fj6-20020a0564022b8600b00564d2bf234dsi6364250edb.253.2024.03.20.03.05.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 03:05:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=k8CTDhkj; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=k8CTDhkj; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-108728-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108728-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 am.mirrors.kernel.org (Postfix) with ESMTPS id EA8E71F22476 for ; Wed, 20 Mar 2024 10:05:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 466333D0C6; Wed, 20 Mar 2024 10:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="k8CTDhkj"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="49Z7V1Iw"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="k8CTDhkj"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="49Z7V1Iw" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAC543D0A3 for ; Wed, 20 Mar 2024 10:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710929123; cv=none; b=px5m/zChEVuBJPDsnnP7o5e+qE5zsORKid2b8yg2m4HZVWNBRhEjFF1VVsRXD6ElVCXCd9TwDLTDlBet59cx7B0M/6qS1UVgJTMBH4zxNoZEAeXY3f6PZV8gTOGWm8CG1g/yErJ9ZZLoDWVANkeOmDiT8RvWbtayoE/l1AX3X60= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710929123; c=relaxed/simple; bh=ampqtZJ9sdTSmxetGEn62AScMj1zcyP3XMQFIM/bIBs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lXQqsg+lEEHtRKUJospTnkRxUwAjBj4F4YCTe/k2m+p7X5Fqml91zzof/M7/INeWghKjy0z5p0iiCD64BI+fSTdHyZxjV2zKngW3NU60yqSwajn9js2t0lcIacS/FXm0vgjlv14OCpTKNbgLEGOW7g1oYcmJBwPdTfiZgtaffXY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=k8CTDhkj; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=49Z7V1Iw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=k8CTDhkj; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=49Z7V1Iw; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B95DB20C45; Wed, 20 Mar 2024 10:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1710929119; h=from:from:reply-to: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=VIZ0ATeO8q/WMl7Af2C8a25lhQGxqN2RZQIjxOdVzdI=; b=k8CTDhkj7YUVNHoYJMZ8PUJbKLS9q30k0VgnRwLxmxX5XbdpAbbs+HRq10Y7P8z/zLfYmm zC5ROqpZDfgY/3zzXaUrQt4aaYrCNiV3m/g0xSOWQS7zqhoohN5bCwL0tM6uf5TnO33eqp NpKMGO6vZd9bYp/8zd1+uNnjUOPoHGo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1710929119; h=from:from:reply-to: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=VIZ0ATeO8q/WMl7Af2C8a25lhQGxqN2RZQIjxOdVzdI=; b=49Z7V1Iw/3iaiVhZqvpFjnczVJ3t2h6XI4E/eSa/Az1tM1dYi20UxTJl7hWi9nH4/o4Kaz iFPhxaZ7mzupH4Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1710929119; h=from:from:reply-to: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=VIZ0ATeO8q/WMl7Af2C8a25lhQGxqN2RZQIjxOdVzdI=; b=k8CTDhkj7YUVNHoYJMZ8PUJbKLS9q30k0VgnRwLxmxX5XbdpAbbs+HRq10Y7P8z/zLfYmm zC5ROqpZDfgY/3zzXaUrQt4aaYrCNiV3m/g0xSOWQS7zqhoohN5bCwL0tM6uf5TnO33eqp NpKMGO6vZd9bYp/8zd1+uNnjUOPoHGo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1710929119; h=from:from:reply-to: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=VIZ0ATeO8q/WMl7Af2C8a25lhQGxqN2RZQIjxOdVzdI=; b=49Z7V1Iw/3iaiVhZqvpFjnczVJ3t2h6XI4E/eSa/Az1tM1dYi20UxTJl7hWi9nH4/o4Kaz iFPhxaZ7mzupH4Cg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1A35A136D6; Wed, 20 Mar 2024 10:05:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id cw/GA9+0+mWBYgAAD6G6ig (envelope-from ); Wed, 20 Mar 2024 10:05:19 +0000 Date: Wed, 20 Mar 2024 11:06:45 +0100 From: Oscar Salvador To: Baolin Wang Cc: akpm@linux-foundation.org, muchun.song@linux.dev, david@redhat.com, linmiaohe@huawei.com, naoya.horiguchi@nec.com, mhocko@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] mm: hugetlb: make the hugetlb migration strategy consistent Message-ID: References: <3519fcd41522817307a05b40fb551e2e17e68101.1709719720.git.baolin.wang@linux.alibaba.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <3519fcd41522817307a05b40fb551e2e17e68101.1709719720.git.baolin.wang@linux.alibaba.com> X-Spam-Score: -4.30 X-Spamd-Result: default: False [-4.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[9]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Spam-Flag: NO On Wed, Mar 06, 2024 at 06:13:27PM +0800, Baolin Wang wrote: > As discussed in previous thread [1], there is an inconsistency when handing > hugetlb migration. When handling the migration of freed hugetlb, it prevents > fallback to other NUMA nodes in alloc_and_dissolve_hugetlb_folio(). However, > when dealing with in-use hugetlb, it allows fallback to other NUMA nodes in > alloc_hugetlb_folio_nodemask(), which can break the per-node hugetlb pool > and might result in unexpected failures when node bound workloads doesn't get > what is asssumed available. > > To make hugetlb migration strategy more clear, we should list all the scenarios > of hugetlb migration and analyze whether allocation fallback is permitted: > 1) Memory offline: will call dissolve_free_huge_pages() to free the freed hugetlb, > and call do_migrate_range() to migrate the in-use hugetlb. Both can break the > per-node hugetlb pool, but as this is an explicit offlining operation, no better > choice. So should allow the hugetlb allocation fallback. > 2) Memory failure: same as memory offline. Should allow fallback to a different node > might be the only option to handle it, otherwise the impact of poisoned memory can > be amplified. > 3) Longterm pinning: will call migrate_longterm_unpinnable_pages() to migrate in-use > and not-longterm-pinnable hugetlb, which can break the per-node pool. But we should > fail to longterm pinning if can not allocate on current node to avoid breaking the > per-node pool. > 4) Syscalls (mbind, migrate_pages, move_pages): these are explicit users operation > to move pages to other nodes, so fallback to other nodes should not be prohibited. > 5) alloc_contig_range: used by CMA allocation and virtio-mem fake-offline to allocate > given range of pages. Now the freed hugetlb migration is not allowed to fallback, to > keep consistency, the in-use hugetlb migration should be also not allowed to fallback. > 6) alloc_contig_pages: used by kfence, pgtable_debug etc. The strategy should be > consistent with that of alloc_contig_range(). > > Based on the analysis of the various scenarios above, introducing a new helper to > determine whether fallback is permitted according to the migration reason.. > > [1] https://lore.kernel.org/all/6f26ce22d2fcd523418a085f2c588fe0776d46e7.1706794035.git.baolin.wang@linux.alibaba.com/ > Signed-off-by: Baolin Wang Reviewed-by: Oscar Salvador > +static inline bool htlb_allow_alloc_fallback(int reason) > +{ > + bool allowed_fallback = false; > + > + /* > + * Note: the memory offline, memory failure and migration syscalls will > + * be allowed to fallback to other nodes due to lack of a better chioce, ^ choice -- Oscar Salvador SUSE Labs