Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1149802ybl; Wed, 8 Jan 2020 11:55:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzkO1uA9Nm0saopROUg4vLIcF9zTJ/MKG3yk2ys2bROgJtmS/UEG/6omVszzILCJSapNxWG X-Received: by 2002:a05:6808:907:: with SMTP id w7mr213895oih.137.1578513302991; Wed, 08 Jan 2020 11:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578513302; cv=none; d=google.com; s=arc-20160816; b=cV7xxQsNtRMafA+d8dpavA4ChjsJ2/tfvVModJz4x4tCjV2NYvKNVbDKkCCXbtzbOP 5evjwlmR+O16k8/iMM/Yso6CdUaDysjWTxsZCMrwUptBCBIkOkrMmncIuoGGP7jRVIY9 RuiZ/Fxx4f+iyQPGCroi0o02wheCbma7SEj9FxP/Hi8SaqD8xi9BogmvWsquM5STnp0F 3LdG3V2kqwWFGB9CK6RVUOokMTBU3qRTlqo0XKTDupdty3HG/N9Twp6wc3wWZsKs8CoM AJat+ctb/q1ISkZRHULyWq7oYlH9gi9aYP8o1qIz4eLwWTTnfvQq/aEdZXhJrm1MBWrs dTJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :mime-version:dkim-signature; bh=A9GrVPmNKNHW3eNzRMPYKqAUKvFyBJyDWBHuMSG+/zM=; b=kwNee5SLIFMv5yWqVtT2S37QmLhpY0SJH/IEXhUi7ckPwdqw5ooFfaa4yu5EtNx9wq sBF4BZarKZG3QwdipUPXp5JaebWBufuIur3fLiu0a+vR8n9FsRgF4KHj3lTYz8oPHLl+ sKlqFsw54dCeejuCMR72XgQ8Nq4xZ+6+wxufDt9qIAlKPnkkMN2WzW4SqUK1eldiOnP3 QFGYLRwnPqa4vLB2uu+7vbgZ0y+NLWiya0A3pqmKA2Gqos8f6qvKbTdim09pzzuUaU0J RRNufrAtKCtIsl4HEXMgP4V4fZ02ZbzPAq6tDcJvyBKRiRQfeEkGtYb5c60W77BCBh/X EYqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QA8K308l; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h128si2243163oif.258.2020.01.08.11.54.51; Wed, 08 Jan 2020 11:55:02 -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=@google.com header.s=20161025 header.b=QA8K308l; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729655AbgAHRHx (ORCPT + 99 others); Wed, 8 Jan 2020 12:07:53 -0500 Received: from mail-oi1-f174.google.com ([209.85.167.174]:46368 "EHLO mail-oi1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729516AbgAHRHx (ORCPT ); Wed, 8 Jan 2020 12:07:53 -0500 Received: by mail-oi1-f174.google.com with SMTP id 13so1384887oij.13 for ; Wed, 08 Jan 2020 09:07:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=A9GrVPmNKNHW3eNzRMPYKqAUKvFyBJyDWBHuMSG+/zM=; b=QA8K308lbSECRq+u12lHYt0gei9CQu0ZdTmZNiW7GZBvTm/2NqY0/43XqT1p9TKsQf LqeEu/EemEIyVKl9rz18hLpeiZHMEENNwTmdAmCdnXEEbc82o50bNq6W1r9g8Kyg68DP CwCRkeRC5ly4trhTWmwIkCMvlgTjJayFLU5v2ynQQ77TbgX2ouXOuTfNAaBFx910Y6X3 ustToSPnxyo59xevMGD5FFMAb+kMCz6r7lC26bogD1LkqW8kyD2EqVps72ytwcn7viAH QhD3SS5hxFAIPUb0LmnzaI1PLxHdt0fe2BeawaUfpE2quTGzKoXDHSZi0Z1fTUmKhCkA 6UFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=A9GrVPmNKNHW3eNzRMPYKqAUKvFyBJyDWBHuMSG+/zM=; b=gFP1fvAce6fYP/yVuzRKLkOMMwUXFtMmCykXUCOzSDZf1ssLA6YC0yrzjTawdKtrHy G45XXA8O+loBtjixiJm6PHAE4AXvEv8s0KWkT88I9xAlNq/JhuzhkZgT5R+vBBWXoAkn 0uH5cwXTLnsJ3NlDWokstHJB/+oN1HEl90bAYnmaQIGHXC5XnhfIlSD8T4JEVYharaaF gnxC7It+OZ3PD9DAiz3WTWtdxvpAQcHLwH5TPGTBdAn2O/cuoHXuFAxupgg894mqkyhc KI4ujIASH41Y0dLFB4pxwyALR4O4k2cJjBcLueS12OzXVcT9OAtglIj2qM4H+j7uO+Du 83lg== X-Gm-Message-State: APjAAAWMWuEiUywFxqjCxtuqjOR8hLnKXIXoT2A5AFHS3w39lhx5dO4y +kFVzH5pjpvYz3eeHhpkBq2FOqMX7CHX6i2KOZhjLXWqHhh4Sw== X-Received: by 2002:a05:6808:30d:: with SMTP id i13mr3661250oie.144.1578503272178; Wed, 08 Jan 2020 09:07:52 -0800 (PST) MIME-Version: 1.0 From: Shakeel Butt Date: Wed, 8 Jan 2020 09:07:41 -0800 Message-ID: Subject: [bug report] resctrl high memory comsumption To: Reinette Chatre , Fenghua Yu , Borislav Petkov , LKML , Thomas Gleixner , Ingo Molnar , x86@kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Recently we had a bug in the system software writing the same pids to the tasks file of resctrl group multiple times. The resctrl code allocates "struct task_move_callback" for each such write and call task_work_add() for that task to handle it on return to user-space without checking if such request already exist for that particular task. The issue arises for long sleeping tasks which has thousands for such request queued to be handled. On our production, we notice thousands of tasks having thousands of such requests and taking GiBs of memory for "struct task_move_callback". I am not very familiar with the code to judge if task_work_cancel() is the right approach or just checking closid/rmid before doing task_work_add(). ==repro== # mkdir /sys/fs/resctrl/test # cat /proc/slabinfo | grep kmalloc-32 kmalloc-32 57219 57288 32 124 1 : tunables 120 60 8 : slabdata 462 462 0 # sleep 600& [1] 17611 # for i in {1..200000}; do echo 17611 > /sys/fs/resctrl/test/tasks ; done # cat /proc/slabinfo | grep kmalloc-32 kmalloc-32 257466 257548 32 124 1 : tunables 120 60 8 : slabdata 2077 2077 5 # kill 17611 [1]+ Terminated sleep 600 # cat /proc/slabinfo | grep kmalloc-32 kmalloc-32 57924 60636 32 124 1 : tunables 120 60 8 : slabdata 470 489 385 thanks, Shakeel