Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752113AbdHNSc4 (ORCPT ); Mon, 14 Aug 2017 14:32:56 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:35839 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdHNScw (ORCPT ); Mon, 14 Aug 2017 14:32:52 -0400 From: Roman Gushchin To: CC: Roman Gushchin , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , David Rientjes , Tejun Heo , , , , Subject: [v5 0/4] cgroup-aware OOM killer Date: Mon, 14 Aug 2017 19:32:10 +0100 Message-ID: <20170814183213.12319-2-guro@fb.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170814183213.12319-1-guro@fb.com> References: <20170814183213.12319-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:ff3d] X-ClientProxiedBy: VI1P194CA0014.EURP194.PROD.OUTLOOK.COM (2603:10a6:800:be::24) To BL2PR15MB1076.namprd15.prod.outlook.com (2603:10b6:201:17::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8766636c-0c48-4070-1b8f-08d4e342d878 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BL2PR15MB1076; X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB1076;3:akpzp9AjOx/EhI+VFs+KbqKh2jlCVJXXTGIpjQgiC9I5F2TyC4qTQDKzVy1izGxz0dmHS8Kwi1VhU003LQT0VbjBawcX5oIqvRK/zBi6laHhprVM5R6VJuCRvND6blcl+NQ4Eyckzu1z+mkrS5pX+Ap0v4gt0nkTDY/HyyjIQf0VDR+z9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aTC7mh7XMuuv5cBKBRA2SUkGS8DHHRFFmGEMolP7Mmq9/vtCNet7LHDBGSJ5OdRa31gf+Kh9Zi0vzufEkswJU4xfRtOSJBOdEWW6LCi/fR9mVXcCbw7vtjfSwtjekYRoyHzronsUYeRsR5vdlLGvrt17wId3Pxhydz9q;4:VWnh620mMnChca7+n7JRHaTqyg/k+a2cHdWiYZRfRtTP4WEoivnCFJlYNrEROBmegIZJAg5dNaSIci5Bn27v7iCKkDWqRZYHJ9iC97w52MSteCHeLhWK37U9cnEF9IqA7L0YPz3zS3Qu5W2CnUlYldbjxrdc5K+4ErcJs1kjeK1cA4Z5iN6fCNoVd8XNSs/lT3j3HI3EA0xlcVFqCH0wnGFJjwunmnVpynJIzLJsL1kp/Z5cUiLJMfHpLpHMujrD X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(20161123558100)(20161123555025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BL2PR15MB1076;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BL2PR15MB1076; X-Forefront-PRVS: 039975700A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6009001)(189002)(199003)(54906002)(6506006)(2906002)(6306002)(76176999)(50986999)(4326008)(42186005)(8676002)(2361001)(50226002)(33646002)(50466002)(7416002)(53416004)(105586002)(106356001)(6116002)(1076002)(5660300001)(48376002)(2351001)(81166006)(81156014)(6486002)(101416001)(68736007)(478600001)(6666003)(110136004)(7736002)(69596002)(53936002)(97736004)(36756003)(6916009)(5003940100001)(189998001)(86362001)(2950100002)(47776003)(6512007)(305945005)(7350300001)(966005)(25786009)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR15MB1076;H:castle.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2PR15MB1076;23:PB+F8mEyd2ppVUUojecCp8wGTF1ujGQ6DUBf5OXQ8?= =?us-ascii?Q?AwTNcwHnSooKBva7sk+dqwj7SUREvWbTycHHwzNatgZp1E7qqF3qUzfinp03?= =?us-ascii?Q?CAezU9wtrshlfqn81i3/sGaEsTkbo+326AM8B/NQvZKK/K+RJrFjOUanMNCi?= =?us-ascii?Q?NfN+E+aR+uCfO+fnzmGfGtCqooZFE3IjjK5bpJ+eQQTyFYYVfwLApDsNFEoM?= =?us-ascii?Q?Ngco4v4AAHd2N8SQaH2wl0JgWnrNGONfYsndd3DK4z7Xf46bO2TyRxNoL79K?= =?us-ascii?Q?EBSFqKkEL4z00lWHybldHUTfQ3EpjSXAXhZlr9G/pC0Fh6RumfNheJ4zMZRf?= =?us-ascii?Q?bI6M9m2Nh3/3aoMoKPON2wBy2KL4N0cqrlPpaV6qFl11xU6k2Ra4IkVFO8ls?= =?us-ascii?Q?vLY+mP6OP1YErt7UyA2YpbN3SnSK8+w8qKmTcH5kTIMijGXTTNI+pBeeXHCa?= =?us-ascii?Q?MwWXovu4VEMIfIE8CXCSgsiwPZ03/hEzx/HnBoQk5IX8WTyBm4zLZSOxfpMN?= =?us-ascii?Q?RjzTkLKY6EAl41BM/+BdoOJrod1+vHMf81Qt/wXsiRoKrpehIMH6VztYdLYk?= =?us-ascii?Q?6U6R2XprcavKGcnrfC7pNms0f1+zWufA3GSTDTItOzsrHWlzcFB8JHkgSEYm?= =?us-ascii?Q?eJRk5rhb2omfRe1/yq0zmUHnaN5k9LxLIActbixIDNcyd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==;5:Cm7hoegoDdfedJX1iFL8qcoqZi1j4JvMbDkCyPLBDpeoszRHbY+qMo/0YroL2cEsPaMPWZUTfzlenS8GmFKP4xaMwH0onv6z/pKYV2dVeBWDDYj30xe1fQu+PbJ3rca16xEp12lbTCuGaKFQ2qB0cXdqJuDjZ8dzj+XgYM8To7c=;24:Mob2awQOEbcvipWkvfIhtA0fdHqQO07vgKtREQnH/QZKe7IcHPcuJtJ8C7yds8T4Ex0shhmgUNpkWERVE4gpgP26GR9W7Kl7ZvDxp3ZhCqk=;7:DagSyA9/gEOkbXEjKDXBZr+4wURrV+e/THneGVma8UQnNjMKzAFdTQEPuNDSm5iuQNS28MjhgUhKg8NZh4Oggg/KLHg3Z/vF7L37ereOJwzxVqJ2v4qYqchhx22vgYb3DUjATl2cXTAI81i6E3Um+tjkGvqn4yXCgg3RBRfZlF/nIb3GfMczRRpsZJrVxP43Bn6FuvH9fZq5z+XGoUd4slFEjOcqmBOzieINhH/0bjM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB1076;20:CzEtIPuletCK1h0XnmTFatExXaBW7gNvbeMZg7xS6DNp/U6OAHOD4tqi+BFY9YZuizhL0lzzpBmSR9vcIrpcPMcgA5w+ulI2ygUVSMb8ZGau3nRU0XcaYWwDeW6O6C8zQX3OGKGXLAchbThrf2/iVnXrd1ssfNTREOrSZdjhFRc= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2017 18:32:38.6272 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR15MB1076 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-14_16:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1854 Lines: 53 This patchset makes the OOM killer cgroup-aware. v5: - Rebased on top of Michal Hocko's patches, which have changed the way how OOM victims becoming an access to the memory reserves. Dropped corresponding part of this patchset - Separated the oom_kill_process() splitting into a standalone commit - Added debug output (suggested by David Rientjes) - Some minor fixes v4: - Reworked per-cgroup oom_score_adj into oom_priority (based on ideas by David Rientjes) - Tasks with oom_score_adj -1000 are never selected if oom_kill_all_tasks is not set - Memcg victim selection code is reworked, and synchronization is based on finding tasks with OOM victim marker, rather then on global counter - Debug output is dropped - Refactored TIF_MEMDIE usage v3: - Merged commits 1-4 into 6 - Separated oom_score_adj logic and debug output into separate commits - Fixed swap accounting v2: - Reworked victim selection based on feedback from Michal Hocko, Vladimir Davydov and Johannes Weiner - "Kill all tasks" is now an opt-in option, by default only one process will be killed - Added per-cgroup oom_score_adj - Refined oom score calculations, suggested by Vladimir Davydov - Converted to a patchset v1: https://lkml.org/lkml/2017/5/18/969 Roman Gushchin (4): mm, oom: refactor the oom_kill_process() function mm, oom: cgroup-aware OOM killer mm, oom: introduce oom_priority for memory cgroups mm, oom, docs: describe the cgroup-aware OOM killer Documentation/cgroup-v2.txt | 62 +++++++++++ include/linux/memcontrol.h | 36 ++++++ include/linux/oom.h | 3 + mm/memcontrol.c | 259 ++++++++++++++++++++++++++++++++++++++++++++ mm/oom_kill.c | 181 +++++++++++++++++++++---------- 5 files changed, 484 insertions(+), 57 deletions(-) -- 2.13.5