Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp56360lqt; Thu, 18 Apr 2024 08:19:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmL7aOBqTenc+6n9cfuVSvA5EoBVW6XStGrT6YblLiG8rtz4TF+YySE84nu7CPaE3y6ImnruX03IEtLp9hd9w2SlQHruYaKBUPR50RSA== X-Google-Smtp-Source: AGHT+IHH5M5Bn4tFnWeF/Ze9ue1Q0dlSjqPxGCrYO6QZkhub0YdMHF9lD+uL53BdV523AQll4BZx X-Received: by 2002:a05:6a20:9192:b0:1a7:3095:b3b9 with SMTP id v18-20020a056a20919200b001a73095b3b9mr4162252pzd.22.1713453565989; Thu, 18 Apr 2024 08:19:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713453565; cv=pass; d=google.com; s=arc-20160816; b=qVXIGhcPLQulW4J/1Cx4FnXIQnVar4DKvX4CWMa30mLZMWecK2Fr28VqdU4x2QTY4z cPcaVj9UMiLLkHtpGqLAAAaLbZMUU4p4mC6xS+QXEHacropq5wI8JF5dOAOuT3DANKQa qcegNkwZpM+9dUGi38JoTXBQdrMnd+PU/sJb8xOZb5A+MHEDhZie71ux8qMM9JDqdbp+ 4O0VlnElxaDHV4VFY9fZloeGTvqzyfCSMrX6CMIXUUIUtKv0HDDpTIvS8ky2XeRU8aIE hIs8xBg+NVKx017uTymuOuy+/TudYK5jEZ5CQ7OiKJFmFbQ/INYosYfLHv/1OoijFmPV tUUA== 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:subject:cc:to :from:dkim-signature; bh=fRqyqZZz/beIO4QHAyMNc12G8bTOX3CjIzAVeMQ2tbU=; fh=AljXfS5uAgxO/gL+BGNrDkLg/rXy4h9J5IBYgPBhMcU=; b=typscQ0ajuw7qTax7dnSwVK3a7lNh7HIEGqQP/v6FQXVobX8YyRo089uYjNmdWRqPt BWAUlnuKTHeioMNQ2Svix25amDG607obIqhipHQxuRFWJHqi8apVv7t9bpGgB7p1YXop 2nHQeucgo9cjtGPlDQsZ6EtESMgNxmgtz0HeCDHvb+BglpcbcROXjSLKPC8nEbQgAHuA xccm9Yl+8rmGLP1rO60s3XxLky3PrxSfDAgfN4sc0pZkZl65CE4VEV/TU/yQnq+TlPXt qazZ4ejAF/y+HjBm9vpU13YMI87GjCpRfFWKaAqmboV85iLVm/WKU1pZLWPRm+ZHCn81 DWpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BWtwB2+e; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-150374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v21-20020a056a00149500b006ea7f4aed70si1644662pfu.199.2024.04.18.08.19.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 08:19:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BWtwB2+e; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-150374-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150374-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0C9F0286775 for ; Thu, 18 Apr 2024 15:18:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C919E16C69D; Thu, 18 Apr 2024 15:18:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BWtwB2+e" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 9422815E20F for ; Thu, 18 Apr 2024 15:18:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713453524; cv=none; b=G8yEnNEGrPMNfJZLbE0yNqm4h6CnEPz+2QidKdd99YZDNhDJ7HWA4K0XP0TrB1ZLOBohHAW/EyBoEI9d8G1Q6VOsZaFIa0Cc/0NwYum8irrdFEglEMDrIgLvFPzQm2VQks0O5my4xdlFelmBD+F2m2J9I6KgwrlzClPZx2SUVo0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713453524; c=relaxed/simple; bh=YwU6TGZyJFBdHkYGxkydvf9mq0nGI6wPqTIcDIgzqqA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Jb4wfi09ha46k5TuaUi6gHdn5sYJ3ukjowvpOY9HqHMqAM2oPpWjv5YcqR6LqPncGqhQGmjsQdyXaRT5Q1xG6DyrvvSJSWOlaJA+eZ6GW/4A+xJy3YSFJ2iMALEL95TvmQAApZOdWnCczDKkQ20wE9YJSLtv+pvORpqmDJeFDe8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BWtwB2+e; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713453521; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=fRqyqZZz/beIO4QHAyMNc12G8bTOX3CjIzAVeMQ2tbU=; b=BWtwB2+e2/eJeBUnN5AnFYwsikW0uNs/370YuD6TnT97dNGTvBS2JLyc/M6TcatB5lp4+a 4JaJDwF0eQ5LRb4MmSayTcRuXxCUJC9KOU3r57Fzppfx68B3ZzJKm5tJCt33+lHQSvyHIz gBbpZtT/a2QFTxRTGr+m+65T9Hl4MJ0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-362-XPqDrA9YMa6ZQad_-ry7Zw-1; Thu, 18 Apr 2024 11:18:37 -0400 X-MC-Unique: XPqDrA9YMa6ZQad_-ry7Zw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56187104B501; Thu, 18 Apr 2024 15:18:37 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62A84C2595D; Thu, 18 Apr 2024 15:18:35 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , John Hubbard , Zi Yan , Matthew Wilcox , Andrew Morton Subject: [PATCH v1] mm/huge_memory: improve split_huge_page_to_list_to_order() return value documentation Date: Thu, 18 Apr 2024 17:18:34 +0200 Message-ID: <20240418151834.216557-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 The documentation is wrong and relying on it almost resulted in BUGs in new callers: we return -EAGAIN on unexpected folio references, not -EBUSY. Let's fix that and also document which other return values we can currently see and why they could happen. Cc: John Hubbard Cc: Zi Yan Cc: Matthew Wilcox Cc: Andrew Morton Signed-off-by: David Hildenbrand --- mm/huge_memory.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index ee12726291f1b..824eff9211db8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2956,7 +2956,7 @@ bool can_split_folio(struct folio *folio, int *pextra_pins) * * 3) The folio must not be pinned. Any unexpected folio references, including * GUP pins, will result in the folio not getting split; instead, the caller - * will receive an -EBUSY. + * will receive an -EAGAIN. * * 4) @new_order > 1, usually. Splitting to order-1 anonymous folios is not * supported for non-file-backed folios, because folio->_deferred_list, which @@ -2975,8 +2975,15 @@ bool can_split_folio(struct folio *folio, int *pextra_pins) * * Returns 0 if the huge page was split successfully. * - * Returns -EBUSY if @page's folio is pinned, or if the anon_vma disappeared - * from under us. + * Returns -EAGAIN if the folio has unexpected reference (e.g., GUP). + * + * Returns -EBUSY when trying to split the huge zeropage, if the folio is + * under writeback, if fs-specific folio metadata cannot currently be + * released, or if some unexpected race happened (e.g., anon VMA disappeared, + * truncation). + * + * Returns -EINVAL when trying to split to an order that is incompatible + * with the folio. Splitting to order 0 is compatible with all folios. */ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list, unsigned int new_order) -- 2.44.0