Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp260399rdb; Mon, 29 Jan 2024 01:01:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXGYASeuecyWRIIXJ72/MkmRaw8TMjssfdvEZSywXrrZy0L6u22XhYS29HW8x5H3zoN23y X-Received: by 2002:a17:90a:e617:b0:293:cfce:a2e0 with SMTP id j23-20020a17090ae61700b00293cfcea2e0mr1644501pjy.11.1706518886722; Mon, 29 Jan 2024 01:01:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706518886; cv=pass; d=google.com; s=arc-20160816; b=mrE53lofR11D6UozqIVcdAp+kzoL+oHyyrpi9mL508SZQPZSVtX4n9t8p5sC2cAens 1UizcOwmBAE3kE2eK69gNM02MPi6uV/kcYgsBIgEvTAJ2i9YR/vItTGS616vk++RgDUO ILZRYQUKhJ9fNipmBgt3i7OraTbB9lqIM8xnEPWXAhDrQJbhv+5SVmXGaWVNY4vYUf34 Vr+LxlTBR3GmWF2iyguw2lBKaBPCvQsjz+CeMo0qKc4jE7OPPGcZfcjVvx1qBY6hkCo2 e5rOW51415R9ov6OlORouskXiQT8r7mX9o9XZJKHxkg+NKocNxaEMXVeafMCrIhOPV5w ioSA== 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:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=II7Bgprp+SYzn56rnFVUzLRY5S1m9HVN/NTpwDYdK5A=; fh=uxLNaPoPRUzmkUc1KOgGwCEU/bTSjK8Yed2Up6ovXLY=; b=HTPq4JZkqWk7SxV01ETYVpQeQMJKirZ+X2IwopPuFrIAhE02oHR/5L2w6wmcqUFjFg Q8r922pEPvm0JQ1lDV3BpK+HtZoK752MjGm9kwumPN2Lom5kCLXznVYkq3mPXMhK7nY4 Dbas5+w67F3Vd/xaBPedS5ckX/ykYy5ySy6pYyeUjHayGIfkEFAcgCWnNI4ht4BJ5uFi hi2RhA3+byjQsn+t1B3uOOeAfiZcyq2lAQN3Ou8tTts6UAL7jQSAOvSKHcH5YYVQG7M6 QthlVfD7bpHvHIV8Y+0opmKvCslWDfvpuRJJNRuNuqoWDktqoGA3aU/7PK1/VeGlaZJX oZLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ztfJnuwv; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-42396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42396-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id sk14-20020a17090b2dce00b002958eec9535si288743pjb.139.2024.01.29.01.01.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 01:01:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ztfJnuwv; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-42396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42396-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A5FDAB20921 for ; Mon, 29 Jan 2024 09:01:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7995754F8D; Mon, 29 Jan 2024 09:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="ztfJnuwv" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 7512754F85 for ; Mon, 29 Jan 2024 09:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706518878; cv=none; b=obtqrKUtLNnLd4e4BhEoVnWzUlKLnVXGqXyhh7kfYBvNRsVcq3iD8jsRawYYQAmnMxcnUOuP4Y7bdYpyyS8ZUpfRUvkVO3rhHpA6SmFyBQA0eo03gIj/Q+B4Q95FqZrbT7U+QqyD1klz7PqWytG2Yk9IBx5WsH8Nf7NUEEhn96o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706518878; c=relaxed/simple; bh=dbkjy2ApaTrI1tg/tWH38LMmQK4tCXE60dntBSxmttQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i7t3bkPRfxXFjXLJemOtNMD4atzQ32lvTvwZUd0J3puD5qbd9VsK98yze6qwiR3kC2K+OTCHoGcH+mLlcWyRSHALmXL/hoeEe+BtNagcRDE5V+7Zcv4eY1xyS9PKwphShvDJUkQ+zvta+cQHLZidyyWb+V79MhdtxInc5ggL6QU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=ztfJnuwv; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706518874; bh=dbkjy2ApaTrI1tg/tWH38LMmQK4tCXE60dntBSxmttQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ztfJnuwvtxR+aEZAbUN8CqdwOda9dMtDLZ6GehCc/+Hb4ioDyu05MEAFy3XbJS6Xx Wia8ikiEZhRQ0W41vTYLg+0yN3+8CcQ8wIbCGhCoJiUM5pw8GQ676E0UdbRAKrNW+L 5U/BNcePpl9wgSIXGLx/nhVkOu9D4O0INrpkBY1JWHjn3ujB0cLH05/8jwQ22kLgur EPb0TWuVsd253crwfMq44kOnXEx+bTxdZb3IdZehMrt3UZOVvQT8J9WiJkvZosVCTK zeaLjXK9U1Biw+z1njFMa0OZBkQGgmWUVk7jMaqMrAsSXVobkwVby0gct/b1qqO7Xm OjIjyQX7gWmSA== Received: from localhost (cola.collaboradmins.com [195.201.22.229]) (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) (Authenticated sender: bbrezillon) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 5A4F137814A4; Mon, 29 Jan 2024 09:01:13 +0000 (UTC) Date: Mon, 29 Jan 2024 10:01:12 +0100 From: Boris Brezillon To: Dmitry Osipenko Cc: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Christian =?UTF-8?B?S8O2bmln?= , Qiang Yu , Steven Price , Emma Anholt , Melissa Wen , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker Message-ID: <20240129100112.35c73f18@collabora.com> In-Reply-To: <20240105184624.508603-23-dmitry.osipenko@collabora.com> References: <20240105184624.508603-1-dmitry.osipenko@collabora.com> <20240105184624.508603-23-dmitry.osipenko@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-redhat-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 5 Jan 2024 21:46:16 +0300 Dmitry Osipenko wrote: > +/** > + * drm_gem_shmem_swapin_locked() - Moves shmem GEM back to memory and enables > + * hardware access to the memory. > + * @shmem: shmem GEM object > + * > + * This function moves shmem GEM back to memory if it was previously evicted > + * by the memory shrinker. The GEM is ready to use on success. > + * > + * Returns: > + * 0 on success or a negative error code on failure. > + */ > +int drm_gem_shmem_swapin_locked(struct drm_gem_shmem_object *shmem) > +{ > + int err; > + > + dma_resv_assert_held(shmem->base.resv); > + > + if (!shmem->evicted) > + return 0; Shouldn't we have a drm_gem_shmem_shrinker_update_lru_locked() even if the object wasn't evicted, such that idle->busy transition moves the BO to the list tail? > + > + err = drm_gem_shmem_acquire_pages(shmem); > + if (err) > + return err; > + > + shmem->evicted = false; > + > + drm_gem_shmem_shrinker_update_lru_locked(shmem); > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(drm_gem_shmem_swapin_locked); > +