From patchwork Wed Feb 15 16:14:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 13141855 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 269E9C64EC4 for ; Wed, 15 Feb 2023 16:15:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1E616B0092; Wed, 15 Feb 2023 11:15:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA72F6B0093; Wed, 15 Feb 2023 11:15:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A477D6B0095; Wed, 15 Feb 2023 11:15:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 946376B0092 for ; Wed, 15 Feb 2023 11:15:48 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2292F1207B6 for ; Wed, 15 Feb 2023 16:15:48 +0000 (UTC) X-FDA: 80470027176.10.3990450 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf09.hostedemail.com (Postfix) with ESMTP id B27C314002E for ; Wed, 15 Feb 2023 16:15:39 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Nhl6uWd2; spf=none (imf09.hostedemail.com: domain of thomas.hellstrom@linux.intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=thomas.hellstrom@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676477746; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GSYV620aTalWXSLcWyRd8YGHIlzKj+cM3LRa7haz9HY=; b=dsZiZOk1tOSHg79oY3N2loTGEyWJ8QmRNUp1mBHY1itotdly+154+Jf+Q/Lek05HlFAx8o J2owNNA/Bkws3EadiHZx3quCeY0QgKSIR5u5+O3rA1RywKA+bNszQUZ9P5t2jHUn/viAi7 j9HFyvo5Jy7gKBusdD9Zi4TAF2Knifc= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Nhl6uWd2; spf=none (imf09.hostedemail.com: domain of thomas.hellstrom@linux.intel.com has no SPF policy when checking 134.134.136.31) smtp.mailfrom=thomas.hellstrom@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676477746; a=rsa-sha256; cv=none; b=00xB/vtArFa3Sng1IqmI1YfD9BsqMHULKVqLJNxzYW2wBoIxCa3sBC1/L8iSNPuVKyYcqA +zE7WTlOP2fMf0FH5dkq/WdxCGWyUVP719+rNoh/fZm/sRyI4cmJAg6gUNBr2LuUYos7Qd WWh6YVBcR85I0ttH3EK4zD6BsHKu1TA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676477745; x=1708013745; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zt1DKEeSn7xRuS1yXMlaTraoBCdZSI/zSbCQL3fb6rc=; b=Nhl6uWd2dmvGkC6cmQoxelu4rsA+ToPeB51PhTj0cXkAEnUEzjnFxVE5 h7RFjWZCNBKvdN7mV+8EkUtVb+2w1xss3RyhynFEWktdrgbXDVAJQS65D 04wXl1KVb5zkHFMgFH+6oHUxGICip94G2ElB7s3bUd55gi4Ks23UekQHv 18l4j36jcLu3zkEPRgT5Y+guZ7v8MZdscGP5DQNJ0YKPPBXRhKlMOpi3A dEE1CeSAfPNXqlSaYU6ASE+vWA9dC78517pQtO7h65/ySfM1MKYpJ6JeH aIDSE9hAmLfkfglon2q6iVCDa0jHu9rAE7rwIHLRj2j9Z1+BswvvQ6tps A==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="393871102" X-IronPort-AV: E=Sophos;i="5.97,300,1669104000"; d="scan'208";a="393871102" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2023 08:15:38 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="758472708" X-IronPort-AV: E=Sophos;i="5.97,300,1669104000"; d="scan'208";a="758472708" Received: from auliel-mobl1.ger.corp.intel.com (HELO thellstr-mobl1.intel.com) ([10.249.254.14]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2023 08:15:30 -0800 From: =?utf-8?q?Thomas_Hellstr=C3=B6m?= To: dri-devel@lists.freedesktop.org Cc: =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Andrew Morton , "Matthew Wilcox (Oracle)" , Miaohe Lin , David Hildenbrand , Johannes Weiner , Peter Xu , NeilBrown , Daniel Vetter , Christian Koenig , Dave Airlie , Dave Hansen , Matthew Auld , linux-graphics-maintainer@vmware.com, linux-mm@kvack.org, intel-gfx@lists.freedesktop.org Subject: [RFC PATCH 13/16] drm/ttm: Make the call to ttm_tt_populate() interruptible when faulting Date: Wed, 15 Feb 2023 17:14:02 +0100 Message-Id: <20230215161405.187368-14-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230215161405.187368-1-thomas.hellstrom@linux.intel.com> References: <20230215161405.187368-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1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uVY58FbhZQYIdmizIV+4z1KDrYnWm yliCJ6up sZTPZ5s6dl8t4r+KCdmmCyZXYxUnqHkp3g0DGCgukfHwVap4qL/skj5wYWMvQ8HjoeFAAshG0cvtLVbdiMfUpF4qFyvFUSLSbpI40ehZXddNvwgFVkzSlJJdlPRUIR3cXYzvLciHdF//0hxibziFozdB0zGuFjxbpu64wbP0i3zhLUIMnYDJOvb7oe3yxbainVu/wZSYPiq/r7bf8Pi5iLPk4g03kXPRbJIDt2gBMAwBCAxU= 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: When swapping in, or under memory pressure ttm_tt_populate() may sleep for a substantiable amount of time. Allow interrupts during the sleep. This will also allow us to inject -EINTR errors during swapin in upcoming patches. Also avoid returning VM_FAULT_OOM, since that will confuse the core mm, making it print out a confused message and retrying the fault. Return VM_FAULT_SIGBUS also under OOM conditions. Signed-off-by: Thomas Hellström --- drivers/gpu/drm/ttm/ttm_bo_vm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 3ecda6db24b8..80f106bfe385 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -218,14 +218,21 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, prot = ttm_io_prot(bo, bo->resource, prot); if (!bo->resource->bus.is_iomem) { struct ttm_operation_ctx ctx = { - .interruptible = false, + .interruptible = true, .no_wait_gpu = false, .force_alloc = true }; ttm = bo->ttm; - if (ttm_tt_populate(bdev, bo->ttm, &ctx)) - return VM_FAULT_OOM; + err = ttm_tt_populate(bdev, bo->ttm, &ctx); + if (err) { + if (err == -EINTR || err == -ERESTARTSYS || + err == -EAGAIN) + return VM_FAULT_NOPAGE; + + pr_debug("TTM fault hit %pe.\n", ERR_PTR(err)); + return VM_FAULT_SIGBUS; + } } else { /* Iomem should not be marked encrypted */ prot = pgprot_decrypted(prot);