Received: by 10.223.176.5 with SMTP id f5csp915411wra; Tue, 30 Jan 2018 21:59:40 -0800 (PST) X-Google-Smtp-Source: AH8x226wcQeQ1M9paPCjl6ivZ3DvB8bRPtxUK42E9AXa70xEeN2G6IEcMX4T9UkTdVrwSW20EX2z X-Received: by 10.99.95.4 with SMTP id t4mr24763687pgb.291.1517378379872; Tue, 30 Jan 2018 21:59:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517378379; cv=none; d=google.com; s=arc-20160816; b=cTGEyYWU4L/prFYmx6KW161QD2uZxpIIBaY2H/2Gq2hrfUnBVvJ27qKt5jstHbFBDy q9+jHQ0fUUNh5/YOOc0/b246SO7O21QTOfbA3M8JbD4a+mWTPtIFzjlZmYHErCZYxDoS Fo6QuAo7VzbkQkQqQdOOeu2ZJo/437YZ43+lm0a0uNPSoRK1t27q17V/+c9kR7CvbYMS JfX/J9XlnHcptq2gpUw1/6mn5cwf1tY4udZolcjcoLl1Ysge0JUQZbI6ThMre2vsoG6P R0HbyXXfb9d3P60S082z1fDSNPnWKg4zgLts1sRzQOViuOojBqmNuXq5UOPQ1PcjDkVV LA0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=0OaQVIkkYjt0qtL1ym3QTrDhO3vaqIUr3UTjyeKEvjQ=; b=kLgp8WLdc9ze2RvDczRRA9K/u5PQXLw0bBMy0HjYR3RiUg9JWOSW30i6qs95WUJhz2 C3+Lurf5AnOR87zxIOmSlcxhuM67wQEVRnTrmQHuD/X/Ebg5Lnd7e5GemfXKBheR5B2Q z7pvb1L2adlUyOLkE1umVjJAnjcgUsqlpMo2PWee+HcZQogUAxBq5vRMreD7yvNmBWIX Fk+b6OFOeGjaI1FKFwlMrI6nnVJz3sMa9Ehjs9cpgp59oOyvX6peEGh3Ea2vLriAL5Cw /Rvt1FGxbMuB0d3caMv7LXKpLQIH/KejnTl9DGSP3tFRqaXMgo9y1yJHsuXF2Aabyur1 Zi6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=ITxVKSVe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z8si638576pgc.83.2018.01.30.21.59.23; Tue, 30 Jan 2018 21:59:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=ITxVKSVe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751910AbeAaFwc (ORCPT + 99 others); Wed, 31 Jan 2018 00:52:32 -0500 Received: from mail-by2nam01on0055.outbound.protection.outlook.com ([104.47.34.55]:19746 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751677AbeAaFwa (ORCPT ); Wed, 31 Jan 2018 00:52:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=0OaQVIkkYjt0qtL1ym3QTrDhO3vaqIUr3UTjyeKEvjQ=; b=ITxVKSVeKvHEv1rfq6CGaCyfPFaXXr6KLzBUSVRqm4z0bBt2HARbsUbe7cR8oKUC67KhvCLcoh9uHw2rISQlBoj8NNuadfCjMAOByqbRGDcsYSSrx6qhSTFO1DoJc7rMH5DTqOwhFPA8E9XWBXiQ6TAVS1XqrpQIbmX6DQxYnkI= Received: from MWHPR1201MB0127.namprd12.prod.outlook.com (10.174.98.142) by MWHPR1201MB2559.namprd12.prod.outlook.com (10.172.98.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Wed, 31 Jan 2018 05:52:27 +0000 Received: from MWHPR1201MB0127.namprd12.prod.outlook.com ([10.174.98.142]) by MWHPR1201MB0127.namprd12.prod.outlook.com ([10.174.98.142]) with mapi id 15.20.0444.016; Wed, 31 Jan 2018 05:52:26 +0000 From: "He, Roger" To: Michal Hocko , "Koenig, Christian" CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" Subject: RE: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages Thread-Topic: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages Thread-Index: AQHTmNtYoBUw/9kRPkGbswRNbnupYaOLC3EAgAClcwCAAFzmgIAAEfKAgAAV3oCAAAQIgIAAIG6AgAEekqA= Date: Wed, 31 Jan 2018 05:52:26 +0000 Message-ID: References: <1517214582-30880-1-git-send-email-Hongbo.He@amd.com> <20180129163114.GH21609@dhcp22.suse.cz> <20180130075553.GM21609@dhcp22.suse.cz> <9060281e-62dd-8775-2903-339ff836b436@amd.com> <20180130101823.GX21609@dhcp22.suse.cz> <7d5ce7ab-d16d-36bc-7953-e1da2db350bf@amd.com> <20180130122853.GC21609@dhcp22.suse.cz> In-Reply-To: <20180130122853.GC21609@dhcp22.suse.cz> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Hongbo.He@amd.com; x-originating-ip: [116.228.147.241] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR1201MB2559;7:jcrC8MpkwYm3iW30VtZO61sMXpAy9u8boW1ZybYFBNZa70vuGEjTGE7OWbFrgT9+loJErMu3wyaihMTc2GlVtsTNMXeat9RPzL69UkfXyO/9nByiFnRKzF3FnaHk86DRbOhuo5X9rZkaMrX8Z/xSW+CIVizWQbSBwgG8Jxo9hh4Jnx8F6hk779aOZqZM7Xol8q08sWtnI1xeqVUl1F4H/As+rawBiuJ0NRI4QRUFGOMWqvJHprz+VkvGuO0uAmpe;20:v5DsjRY8tB+8OnAeWzltne2eSyw28G8DocD8dAfdw9cnwRyl/jobzE5NZ4XL8ECqkDFuyIHIT7/M/jQY8VDO2n7eqq31xj/Kpw1mlFa65o1ogIeINjGBOb91AijIYEZEXaQTGNQipSamYj7F+XC3oN0oXb9AGqgbXkKxDRD0rqwpS85xOFBsVhMHD7ByYeylpFoqig09A5FQIViaoWkeoxTPoF/2YM0U7osMtIUeMD46yxiffG/W41R+KOZgjE1m x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(376002)(366004)(39860400002)(346002)(396003)(39380400002)(377424004)(13464003)(189003)(199004)(86362001)(3280700002)(54906003)(105586002)(110136005)(26005)(6246003)(14454004)(97736004)(93886005)(186003)(316002)(3660700001)(7696005)(59450400001)(4326008)(77096007)(72206003)(99286004)(478600001)(76176011)(25786009)(66066001)(102836004)(106356001)(55016002)(2906002)(53546011)(6506007)(2900100001)(6116002)(7736002)(305945005)(74316002)(3846002)(8676002)(8936002)(81156014)(81166006)(6636002)(9686003)(2950100002)(33656002)(5660300001)(53936002)(68736007)(229853002)(6436002);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR1201MB2559;H:MWHPR1201MB0127.namprd12.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 48bf06e1-62b5-49ab-6b8c-08d5686ecec6 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020);SRVR:MWHPR1201MB2559; x-ms-traffictypediagnostic: MWHPR1201MB2559: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(278428928389397)(9452136761055)(767451399110)(217544274631240); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231101)(2400082)(944501161)(10201501046)(3002001)(6055026)(6041288)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011);SRVR:MWHPR1201MB2559;BCL:0;PCL:0;RULEID:;SRVR:MWHPR1201MB2559; x-forefront-prvs: 056929CBB8 received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: GnK71ZnkSoDUoRSEhs9AlX06l8Nl6S5X5QoaXLxrewFYMKEj65AhdjXN8us3jAXwRugqTlUJ8xYGMf2E7T7oLg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48bf06e1-62b5-49ab-6b8c-08d5686ecec6 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jan 2018 05:52:26.6657 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB2559 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I do think you should completely ignore the size of the swap space. IMHO y= ou should forbid further allocations when your current buffer storage cann= ot be reclaimed. So you need some form of feedback mechanism that would tel= l you: "Your buffers have grown too much". If you cannot do that then simp= ly assume that you cannot swap at all rather than rely on having some porti= on of it for yourself.=20 If we assume the swap cache size is zero always, that is overkill for GTT s= ize actually user can get. And not make sense as well I think. There are many other users of memory outside of your subsystem. Any scalin= g based on the 50% of resource belonging to me is simply broken. And that is only a threshold to avoid overuse rather than really reserved= to TTM at the start. In addition, for most cases TTM only uses a little or= not use swap disk at all. Only special test case use more or probably that= is intentional. Thanks Roger(Hongbo.He) -----Original Message----- From: Michal Hocko [mailto:mhocko@kernel.org]=20 Sent: Tuesday, January 30, 2018 8:29 PM To: Koenig, Christian Cc: He, Roger ; linux-mm@kvack.org; linux-kernel@vger.ke= rnel.org; dri-devel@lists.freedesktop.org Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose t= otal_swap_pages On Tue 30-01-18 11:32:49, Christian K=F6nig wrote: > Am 30.01.2018 um 11:18 schrieb Michal Hocko: > > On Tue 30-01-18 10:00:07, Christian K=F6nig wrote: > > > Am 30.01.2018 um 08:55 schrieb Michal Hocko: > > > > On Tue 30-01-18 02:56:51, He, Roger wrote: > > > > > Hi Michal: > > > > >=20 > > > > > We need a API to tell TTM module the system totally has how=20 > > > > > many swap cache. Then TTM module can use it to restrict how=20 > > > > > many the swap cache it can use to prevent triggering OOM. For=20 > > > > > Now we set the threshold of swap size TTM used as 1/2 * total=20 > > > > > size and leave the rest for others use. > > > > Why do you so much memory? Are you going to use TB of memory on=20 > > > > large systems? What about memory hotplug when the memory is added/r= eleased? > > > For graphics and compute applications on GPUs it isn't unusual to=20 > > > use large amounts of system memory. > > >=20 > > > Our standard policy in TTM is to allow 50% of system memory to be=20 > > > pinned for use with GPUs (the hardware can't do page faults). > > >=20 > > > When that limit is exceeded (or the shrinker callbacks tell us to=20 > > > make room) we wait for any GPU work to finish and copy buffer=20 > > > content into a shmem file. > > >=20 > > > This copy into a shmem file can easily trigger the OOM killer if=20 > > > there isn't any swap space left and that is something we want to avoi= d. > > >=20 > > > So what we want to do is to apply this 50% rule to swap space as=20 > > > well and deny allocation of buffer objects when it is exceeded. > > How does that help when the rest of the system might eat swap? >=20 > Well it doesn't, but that is not the problem here. >=20 > When an application keeps calling malloc() it sooner or later is=20 > confronted with an OOM killer. >=20 > But when it keeps for example allocating OpenGL textures the=20 > expectation is that this sooner or later starts to fail because we run=20 > out of memory and not trigger the OOM killer. There is nothing like running out of memory and not triggering the OOM kill= er. You can make a _particular_ allocation to bail out without the oom kill= er. Just use __GFP_NORETRY. But that doesn't make much difference when you = have already depleted your memory and live with the bare remainings. Any de= sperate soul trying to get its memory will simply trigger the OOM. > So what we do is to allow the application to use all of video memory +=20 > a certain amount of system memory + swap space as last resort fallback (e= .g. > when you Alt+Tab from your full screen game back to your browser). >=20 > The problem we try to solve is that we haven't limited the use of swap=20 > space somehow. I do think you should completely ignore the size of the swap space. IMHO yo= u should forbid further allocations when your current buffer storage cannot= be reclaimed. So you need some form of feedback mechanism that would tell = you: "Your buffers have grown too much". If you cannot do that then simply = assume that you cannot swap at all rather than rely on having some portion = of it for yourself. There are many other users of memory outside of your su= bsystem. Any scaling based on the 50% of resource belonging to me is simply= broken. -- Michal Hocko SUSE Labs