Received: by 10.213.65.68 with SMTP id h4csp1308524imn; Wed, 4 Apr 2018 17:01:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+WdsaATXac7wnC2kAx/U1/EqlzCiTIlnUj+7/6+2dIY6t4cElCQg1XKiPb6enm3db0jcFR X-Received: by 10.98.204.12 with SMTP id a12mr15385738pfg.3.1522886462692; Wed, 04 Apr 2018 17:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522886462; cv=none; d=google.com; s=arc-20160816; b=dpgPr/WP0BpvE51duSFtxU0MjPkn7FWblzDygw3/st3qXTxYVzf/1EHTIdfLZeR3uC My8lepYuekkAYrITT4ktt0nnP/ykHBFxLxAFQvWwebcEhtnUyT+5j0V1YEVoEjKIrkaW lagUgs5ULIyl74l1c5oc+4yR+nZKgNF0Mj/QWoJHben340APFnlZZnqorK7oD7BnC1tR QbTg27QuxEsUlhz/58GMtc+uaC2d58iCaqPS11BS8PRAJiD5sdZI7ESz0DNgRyUgckxQ BjzNIMf6wGT2VWMc9QdOXp1Q/D8zLVTjzqbBDHNZyVqKJgTScMJAiMvsWR/nEpFeho15 EPyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=FDB/xPVS4Q7WYJhSWmSdQSLgkKVmq7dYVIbnUHwZ/Jg=; b=CojGQddHyI0Vwsbih6ykX19b9ghWii3LcAnvzwrBBR2PWDMY2/Z6bI2CgQPX/CeDWH lIPJxOjpidhkLspRFRkShOcomhSrR+oHNJqaJtpVfOPg3ic9L5I6+A9PecZYwnSvgZ8p ZYkuyaNuTFyMdlPWqlrtSU38n0MoKoFicoIY5Yt4K5dBb9p6GNvMK/cNaBisJ65AkgHM YX7QgAHwFegsxzWIXZcdNv+Rr/GD8snI4jjDrh1K8qaJ2M1x3XVH1LFWJGK0XyQXlkVK Z4Mg2KQ4QUthMBerFZM4GlaPM22LP/pQfqGgNm4fZDyAk6IgG9/p6+hdKllny7qlh5Fb FXjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=bZok4dex; 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 q26si4352666pgv.585.2018.04.04.17.00.48; Wed, 04 Apr 2018 17:01:02 -0700 (PDT) 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=bZok4dex; 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 S1752849AbeDDX7Y (ORCPT + 99 others); Wed, 4 Apr 2018 19:59:24 -0400 Received: from mail-it0-f47.google.com ([209.85.214.47]:35844 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752484AbeDDX7U (ORCPT ); Wed, 4 Apr 2018 19:59:20 -0400 Received: by mail-it0-f47.google.com with SMTP id 15-v6so1026995itl.1 for ; Wed, 04 Apr 2018 16:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=FDB/xPVS4Q7WYJhSWmSdQSLgkKVmq7dYVIbnUHwZ/Jg=; b=bZok4dexq0heEumRia08PGLIXBb9TYxwGH1bnMMTtoODqjRb/HPRyKC/YB1wD7+q/o ehY88lfezzHXSlAolwhrSPSnPTf94f4f1R/n1YP+CjOSwZlOL+qSvcLP4CZ0Ly3oVrfx GhaRV3O5kM3YoU7daUxLeiIeXMna3eLKcwqRl83ZFERndIaIDsYg1NipT81XrBxMfc2m oQ5vFt1jkKNp/YC6dF/giKp3OmCEZL6fdMG51r/gTlFFtX69QFLCf03tfMMCuW13F5mM VOptwBJ/yOU9j60X7slFTHUwyIOtGt65wO9IZl/TCUMarta/1v1B/y8PDtRbo284mefC G/nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=FDB/xPVS4Q7WYJhSWmSdQSLgkKVmq7dYVIbnUHwZ/Jg=; b=slsF5Copgk2UzZXv/SA5fftKwOXygcmYbtmWpvXYZucuygL1wWIOZR6rHKQvZY+xOQ y+vPPzDZHe1uB/mzD/ZyUUGcjUN6tBZjahKcnxHeuiPqLaGYkSrDaIqQK328mDIvNZn/ Cw4LGWJJvpKMWNk9wZSG+7IecvtHpjj8qJK8PLqseGcAbdUy3+t7+lM1OZCRptmt7dnx q8Ay3cgWMzsN85RlNaZ3WVaUX1n58Ee5WRsBkCaWcKK4YHBx9Avzj+N3q0xaQCoK2pHQ oAivSrLztex3XKRHppnVG51ZWc37haXf6IEsoZuasvFxTjP0x78U9pWkijErlmdSFEu9 1z3w== X-Gm-Message-State: ALQs6tAXVIkvYTOoKF9+4qFy/F2/T8AgA5vh7vw8/0ZXcm1johQ9Y0y9 B5q58erhtMOWlDy7JGKHXU632eg+iL4SteptiQRtcg== X-Received: by 2002:a24:cd45:: with SMTP id l66-v6mr12263600itg.151.1522886359232; Wed, 04 Apr 2018 16:59:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.11.158 with HTTP; Wed, 4 Apr 2018 16:59:18 -0700 (PDT) In-Reply-To: References: <20180404115310.6c69e7b9@gandalf.local.home> <20180404120002.6561a5bc@gandalf.local.home> <20180404121326.6eca4fa3@gandalf.local.home> From: Joel Fernandes Date: Wed, 4 Apr 2018 16:59:18 -0700 Message-ID: Subject: Re: [PATCH] ring-buffer: Add set/clear_current_oom_origin() during allocations To: Steven Rostedt Cc: LKML , Michal Hocko , Zhaoyang Huang , Ingo Molnar , kernel-patch-test@lists.linaro.org, Andrew Morton , "open list:MEMORY MANAGEMENT" , Vlastimil Babka 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 Steve, On Wed, Apr 4, 2018 at 9:18 AM, Joel Fernandes wrote: > On Wed, Apr 4, 2018 at 9:13 AM, Steven Rostedt wrote: > [..] >>> >>> Also, I agree with the new patch and its nice idea to do that. >> >> Thanks, want to give it a test too? With the latest tree and the below diff, I can still OOM-kill a victim process doing a large buffer_size_kb write: I pulled your ftrace/core and added this: + /* i = si_mem_available(); if (i < nr_pages) return -ENOMEM; + */ Here's a run in Qemu with 4-cores 1GB total memory: bash-4.3# ./m -m 1M & [1] 1056 bash-4.3# bash-4.3# bash-4.3# bash-4.3# echo 10000000 > /d/tracing/buffer_size_kb [ 33.213988] Out of memory: Kill process 1042 (bash) score 1712050900 or sacrifice child [ 33.215349] Killed process 1056 (m) total-vm:9220kB, anon-rss:7564kB, file-rss:4kB, shmem-rss:640kB bash: echo: write error: Cannot allocate memory [1]+ Killed ./m -m 1M bash-4.3# -- As you can see, OOM killer triggers and kills "m" which is my busy memory allocator (it allocates and frees lots of memory and does that in a loop) Here's the m program, sorry if it looks too ugly: https://pastebin.com/raw/aG6Qw37Z Happy to try anything else, BTW when the si_mem_available check enabled, this doesn't happen and the buffer_size_kb write fails normally without hurting anything else. - Joel