From patchwork Fri Jul 15 10:35:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Topi Miettinen X-Patchwork-Id: 9231643 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2598460865 for ; Fri, 15 Jul 2016 10:41:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15E3B262F2 for ; Fri, 15 Jul 2016 10:41:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A95328324; Fri, 15 Jul 2016 10:41:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC41262F2 for ; Fri, 15 Jul 2016 10:41:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932521AbcGOKl1 (ORCPT ); Fri, 15 Jul 2016 06:41:27 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33808 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932531AbcGOKhT (ORCPT ); Fri, 15 Jul 2016 06:37:19 -0400 Received: by mail-wm0-f65.google.com with SMTP id q128so1755563wma.1; Fri, 15 Jul 2016 03:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/jBD/DRi2KzePiSRGp72B5Ku/nZFE2ayIioX2mTsFl4=; b=0qZdq216QJpz+qyyBusaHbUVtFLx2HTMNoJ0N8A+Fovpqdrg6gXQMhrczU96EPzs1v KojMd2WX05r3CRXzIAN9hFGRRmDpKq/HP3DEvRU1gStIvZEdYHlTA+t6Dgub7wKorLgK 98Qudk5n3ytMitlhDNBm5t9LBv54ZGur9q1anbrR5cg+v5BGPhmctvrl/Dal5bj782BL TJUdLHaSSk9SzAlowBJNw6MYUhsF0neu3z2fvCKZ6htr0VYavYB9NcrCKV4Gqcu/OyQJ iuXDD8ExSN32A/QMy1/KCnn2CKytos/0IULjKP6I7nG02WHcbs7rnIcGNwIkeTwyqh1p TVkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/jBD/DRi2KzePiSRGp72B5Ku/nZFE2ayIioX2mTsFl4=; b=Wxl3eTd83zScFkRrzTCf7/DY6iwRWD2i9c1MTgMWy0vyF/1vMbCuB1b170O9ksYTzP pHc6tyJsAYu2CknOl+I3vN5w7IMB19T50s4pK7+l7AgCRbBpDQ+dVAWsmbgUGmHmLaox RhMybRhIfwQNJF624aDGw44L2gmVcuy6WQnWtpD3BOXinvcAwf88jLqwU5BJts2O10jQ v3oEoOTVxkZBPRfaLrE/PBNZ31JZ6Q2YMQva6CUOe7tXfx2A7hiY8y1vR6hDScklIdAJ NVDnN+zBYE5DrqZA7UID2QQArZw7VLlBu0sHNqwjvAPlOVfnYw+fG1UoJJgjEGPuTYOa TA1A== X-Gm-Message-State: ALyK8tKGG83WI2hXP8P4kdiBXNZZo4EUXrv4HjFZxIo1g++lNR2YVGfdFpeKzbWwlM+RCg== X-Received: by 10.28.30.1 with SMTP id e1mr11128160wme.77.1468579037810; Fri, 15 Jul 2016 03:37:17 -0700 (PDT) Received: from localhost.localdomain ([2001:2003:f54a:b700:2ab2:bdff:fe10:799e]) by smtp.gmail.com with ESMTPSA id jq9sm60564wjb.38.2016.07.15.03.37.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jul 2016 03:37:17 -0700 (PDT) From: Topi Miettinen To: linux-kernel@vger.kernel.org Cc: Topi Miettinen , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Alexander Viro , Andrew Morton , Michal Hocko , Vlastimil Babka , Ben Segall , Alex Thorlton , Mateusz Guzik , John Stultz , "Kirill A. Shutemov" , Oleg Nesterov , Chen Gang , Konstantin Khlebnikov , Andrea Arcangeli , Andrey Ryabinin , linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure)), linux-mm@kvack.org (open list:MEMORY MANAGEMENT) Subject: [PATCH 04/14] resource limits: track highwater mark of VM data segment Date: Fri, 15 Jul 2016 13:35:51 +0300 Message-Id: <1468578983-28229-5-git-send-email-toiwoton@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1468578983-28229-1-git-send-email-toiwoton@gmail.com> References: <1468578983-28229-1-git-send-email-toiwoton@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Track maximum size of data VM, to be able to configure RLIMIT_DATA resource limits. The information is available with taskstats and cgroupstats netlink socket. Signed-off-by: Topi Miettinen --- arch/x86/ia32/ia32_aout.c | 2 ++ fs/binfmt_aout.c | 2 ++ fs/binfmt_flat.c | 2 ++ kernel/sys.c | 3 +++ mm/mmap.c | 7 ++++++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c index cb26f18..9236254 100644 --- a/arch/x86/ia32/ia32_aout.c +++ b/arch/x86/ia32/ia32_aout.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -398,6 +399,7 @@ beyond_if: regs->r8 = regs->r9 = regs->r10 = regs->r11 = regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0; set_fs(USER_DS); + update_resource_highwatermark(RLIMIT_DATA, ex.a_data + ex.a_bss); return 0; } diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index ae1b540..49216f4 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -330,6 +331,7 @@ beyond_if: regs->gp = ex.a_gpvalue; #endif start_thread(regs, ex.a_entry, current->mm->start_stack); + update_resource_highwatermark(RLIMIT_DATA, ex.a_data + ex.a_bss); return 0; } diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index caf9e39..19c2212 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -792,6 +793,7 @@ static int load_flat_file(struct linux_binprm * bprm, libinfo->lib_list[id].start_brk) + /* start brk */ stack_len); + update_resource_highwatermark(RLIMIT_DATA, data_len + bss_len); return 0; err: return ret; diff --git a/kernel/sys.c b/kernel/sys.c index 89d5be4..d84c87e 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1896,6 +1896,9 @@ static int prctl_set_mm_map(int opt, const void __user *addr, unsigned long data if (prctl_map.auxv_size) memcpy(mm->saved_auxv, user_auxv, sizeof(user_auxv)); + update_resource_highwatermark(RLIMIT_DATA, mm->end_data - + mm->start_data); + up_write(&mm->mmap_sem); return 0; } diff --git a/mm/mmap.c b/mm/mmap.c index de2c176..0b10f56 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -228,6 +228,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) goto out; set_brk: + update_resource_highwatermark(RLIMIT_DATA, (brk - mm->start_brk) + + (mm->end_data - mm->start_data)); mm->brk = brk; populate = newbrk > oldbrk && (mm->def_flags & VM_LOCKED) != 0; up_write(&mm->mmap_sem); @@ -2924,8 +2926,11 @@ void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages) mm->exec_vm += npages; else if (is_stack_mapping(flags)) mm->stack_vm += npages; - else if (is_data_mapping(flags)) + else if (is_data_mapping(flags)) { mm->data_vm += npages; + update_resource_highwatermark(RLIMIT_DATA, + mm->data_vm << PAGE_SHIFT); + } } static int special_mapping_fault(struct vm_area_struct *vma,