Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3976541pxb; Tue, 25 Jan 2022 00:27:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGObHvQxdNOJPXv9M5sFPsiWXMmelzuG+RogPam2MgQ0V3+E4DrdAFyApHU2wU62O4ArpN X-Received: by 2002:a17:906:7801:: with SMTP id u1mr15028743ejm.82.1643099221924; Tue, 25 Jan 2022 00:27:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099221; cv=none; d=google.com; s=arc-20160816; b=dHacfPM/HhquHvA9GeCS12PIxoogMNabM99mQAKDwl2Q0zs56AvKVno2q2Q19VDwpc Zrsnvu6317i0H7Y3TAgM3xZD/xk4XKJ0OFm8dD0l6KzDBLk2tN9h/eXFKvmMuww+60Ci CvBi3EL/Nv0aO5IpwanfFdxSiDLV/aMHY59JQjthFLExGxez1jgmsCeiMtnDHf/pOrKH xz52VO4DUI/jPqEdG2Tz9H1z3xGx4Rg8DmhGvkVlY7g4FL5bbz+Tgc1AwQCrcHmE6thu qP96uaY3jvnmiEY2c0N8XkLgv5mJHbuKMM2QM/ELy4bkheW4rMcpHaFirLdimHRThkzr K/Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IDWHQyWbfc4BwbYUgPb4MzM0/CIklAzsKYX5dwK8s5Q=; b=Kjt49K1jWQ96zpH0cv7nCk2ijiUzWyyhC6p+3ZkrbxKR0SO/M2Ajc+/G2cdpLSZ9W9 z5jvmYPQo8j6/nw+EKjj1WXK7l+xm6q9o5GzexlyZ+9Bnalykdx1m6jA+05lBRNCDSFB Bt78+hJi2CGxm42bl8RhELNrrpyYhGexEHbye/l9ew9RqlKVlC9XhZOg5bQ2MGpEfkCj /xQODpvFL9Cwa8kPSEOXAz/iH4I1mrPnk4HDrF4n3DKayuFmzAd41Jq/mMmx1L7wwH5O OACV7mXl7EoWI4sXgCb2TyqsOA2CeNbx2nCs3S+LH+t7YWhHmUtqy699Se0Hm+gL+H5V 6iUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BGGPjo56; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id go12si9221445ejc.678.2022.01.25.00.26.37; Tue, 25 Jan 2022 00:27:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BGGPjo56; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S3422426AbiAYCbN (ORCPT + 99 others); Mon, 24 Jan 2022 21:31:13 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:41546 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379857AbiAXUSp (ORCPT ); Mon, 24 Jan 2022 15:18:45 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 026826137F; Mon, 24 Jan 2022 20:18:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB09FC340E5; Mon, 24 Jan 2022 20:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055524; bh=HSxRMnnIcvZPJXsCIuf6LoytL1ueL7M7WfSENNqP6UU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BGGPjo56xXI6D36qH2Bn8AYh9IoRFi7NzEcn5d+uYKcM9K2bC4AuMqYBh6POJhIMS 5tpsalSUNe852chXw/X3C7AJ5/+iosyzrloBOaSYEtwtevvRZAEfNgco+gEU8HcL4a IIxsYmTrLHmbp7x2HyQtmUeuf295WIn+cefNJcWk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zack Rusin , Martin Krastev , Sasha Levin Subject: [PATCH 5.15 178/846] drm/vmwgfx: Remove the deprecated lower mem limit Date: Mon, 24 Jan 2022 19:34:55 +0100 Message-Id: <20220124184107.115323736@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zack Rusin [ Upstream commit 826c387d015247df396a91eadbaca94f0394853c ] TTM during the transition to the new page allocator lost the ability to constrain the allocations via the lower_mem_limit. The code has been unused since the change: 256dd44bd897 ("drm/ttm: nuke old page allocator") and there's no reason to keep it. Fixes: 256dd44bd897 ("drm/ttm: nuke old page allocator") Signed-off-by: Zack Rusin Reviewed-by: Martin Krastev Link: https://patchwork.freedesktop.org/patch/msgid/20211105193845.258816-2-zackr@vmware.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/vmwgfx/ttm_memory.c | 99 +---------------------------- drivers/gpu/drm/vmwgfx/ttm_memory.h | 6 +- 2 files changed, 2 insertions(+), 103 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/ttm_memory.c b/drivers/gpu/drm/vmwgfx/ttm_memory.c index edd17c30d5a51..2ced4c06ca451 100644 --- a/drivers/gpu/drm/vmwgfx/ttm_memory.c +++ b/drivers/gpu/drm/vmwgfx/ttm_memory.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -173,69 +172,7 @@ static struct kobj_type ttm_mem_zone_kobj_type = { .sysfs_ops = &ttm_mem_zone_ops, .default_attrs = ttm_mem_zone_attrs, }; - -static struct attribute ttm_mem_global_lower_mem_limit = { - .name = "lower_mem_limit", - .mode = S_IRUGO | S_IWUSR -}; - -static ssize_t ttm_mem_global_show(struct kobject *kobj, - struct attribute *attr, - char *buffer) -{ - struct ttm_mem_global *glob = - container_of(kobj, struct ttm_mem_global, kobj); - uint64_t val = 0; - - spin_lock(&glob->lock); - val = glob->lower_mem_limit; - spin_unlock(&glob->lock); - /* convert from number of pages to KB */ - val <<= (PAGE_SHIFT - 10); - return snprintf(buffer, PAGE_SIZE, "%llu\n", - (unsigned long long) val); -} - -static ssize_t ttm_mem_global_store(struct kobject *kobj, - struct attribute *attr, - const char *buffer, - size_t size) -{ - int chars; - uint64_t val64; - unsigned long val; - struct ttm_mem_global *glob = - container_of(kobj, struct ttm_mem_global, kobj); - - chars = sscanf(buffer, "%lu", &val); - if (chars == 0) - return size; - - val64 = val; - /* convert from KB to number of pages */ - val64 >>= (PAGE_SHIFT - 10); - - spin_lock(&glob->lock); - glob->lower_mem_limit = val64; - spin_unlock(&glob->lock); - - return size; -} - -static struct attribute *ttm_mem_global_attrs[] = { - &ttm_mem_global_lower_mem_limit, - NULL -}; - -static const struct sysfs_ops ttm_mem_global_ops = { - .show = &ttm_mem_global_show, - .store = &ttm_mem_global_store, -}; - -static struct kobj_type ttm_mem_glob_kobj_type = { - .sysfs_ops = &ttm_mem_global_ops, - .default_attrs = ttm_mem_global_attrs, -}; +static struct kobj_type ttm_mem_glob_kobj_type = {0}; static bool ttm_zones_above_swap_target(struct ttm_mem_global *glob, bool from_wq, uint64_t extra) @@ -435,11 +372,6 @@ int ttm_mem_global_init(struct ttm_mem_global *glob, struct device *dev) si_meminfo(&si); - spin_lock(&glob->lock); - /* set it as 0 by default to keep original behavior of OOM */ - glob->lower_mem_limit = 0; - spin_unlock(&glob->lock); - ret = ttm_mem_init_kernel_zone(glob, &si); if (unlikely(ret != 0)) goto out_no_zone; @@ -527,35 +459,6 @@ void ttm_mem_global_free(struct ttm_mem_global *glob, } EXPORT_SYMBOL(ttm_mem_global_free); -/* - * check if the available mem is under lower memory limit - * - * a. if no swap disk at all or free swap space is under swap_mem_limit - * but available system mem is bigger than sys_mem_limit, allow TTM - * allocation; - * - * b. if the available system mem is less than sys_mem_limit but free - * swap disk is bigger than swap_mem_limit, allow TTM allocation. - */ -bool -ttm_check_under_lowerlimit(struct ttm_mem_global *glob, - uint64_t num_pages, - struct ttm_operation_ctx *ctx) -{ - int64_t available; - - /* We allow over commit during suspend */ - if (ctx->force_alloc) - return false; - - available = get_nr_swap_pages() + si_mem_available(); - available -= num_pages; - if (available < glob->lower_mem_limit) - return true; - - return false; -} - static int ttm_mem_global_reserve(struct ttm_mem_global *glob, struct ttm_mem_zone *single_zone, uint64_t amount, bool reserve) diff --git a/drivers/gpu/drm/vmwgfx/ttm_memory.h b/drivers/gpu/drm/vmwgfx/ttm_memory.h index c50dba7744854..7b0d617ebcb1e 100644 --- a/drivers/gpu/drm/vmwgfx/ttm_memory.h +++ b/drivers/gpu/drm/vmwgfx/ttm_memory.h @@ -50,8 +50,6 @@ * @work: The workqueue callback for the shrink queue. * @lock: Lock to protect the @shrink - and the memory accounting members, * that is, essentially the whole structure with some exceptions. - * @lower_mem_limit: include lower limit of swap space and lower limit of - * system memory. * @zones: Array of pointers to accounting zones. * @num_zones: Number of populated entries in the @zones array. * @zone_kernel: Pointer to the kernel zone. @@ -69,7 +67,6 @@ extern struct ttm_mem_global { struct workqueue_struct *swap_queue; struct work_struct work; spinlock_t lock; - uint64_t lower_mem_limit; struct ttm_mem_zone *zones[TTM_MEM_MAX_ZONES]; unsigned int num_zones; struct ttm_mem_zone *zone_kernel; @@ -91,6 +88,5 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page, uint64_t size); size_t ttm_round_pot(size_t size); -bool ttm_check_under_lowerlimit(struct ttm_mem_global *glob, uint64_t num_pages, - struct ttm_operation_ctx *ctx); + #endif -- 2.34.1