Received: by 10.213.65.68 with SMTP id h4csp34577imn; Fri, 30 Mar 2018 13:39:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx48u9nfkPRTok5G9LvJFqQeVIndIW6qTbu07kk64mX5M8G1mdrALP8H1JTH2GMHeM00fRM3c X-Received: by 10.98.68.135 with SMTP id m7mr362969pfi.57.1522442348285; Fri, 30 Mar 2018 13:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522442348; cv=none; d=google.com; s=arc-20160816; b=U1NFuQSORqexoSsiQk66uFl9Nh05iAXrxUc0Oy9PbNpwYTkFj00wwe7ORlpkppOWIJ H7DK9jv3x+p3vLgC7Dg5Yi+gldOshq3i2sdQUNN+NM5Hl145R0isV7sLwp6+uf5WOPl6 7/EN9vVwjRLYIAIUNj4ldbHNO7rOqKrTqZiJ/UW09VURDXimTWM9nW3foppLEo5lZN7H 6gUrEixIv9AXA5A8zql+B+Zu3XlgqYhnTv8ORBcjirBeKpuC6qi29lW/kRP6MACaSesC TCmzdyuUtqvr0KM2GIFiX5YpF6FP3oz9gKIGj5WlTsJUObMm+FD8RiYcc+fYggonoo0D D+CQ== 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=wMrNzl/VuGrnW12NVUE1/6AZFoyqXR4UAHbZR6LERHE=; b=pbryPHU1A9Apja9kfeOg0jLzKiSfvYJ4cT3pNEVvstOucNdDtTJExRMolH0f1Tum3i 7QOgrCOK+LyJb17/eF5IMqL7CZBJsK+skt0oy2rTcf7uzD5MvfOwg38fiZ2w5qA+bg6D r1qkNMpSkiKOTBXGx9qeAQbYj12M9VKnp4dpgZdt6aXxukx1RmxriYTmOHC+dawxXVeZ kAigkNe5NAC01FA9w3SePa7lpFVtwGOk8UaCc7s5zrDmidufq3MWILqpa/peK8TVirzx f1dpote7VX0gYh94JFzThjIKo9L+7YSzZ26KrL19UYknYxAixrw5zeZ0gyhCV7vGdFmp eYrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tzpbbzIX; 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 y15si6652212pfe.184.2018.03.30.13.38.51; Fri, 30 Mar 2018 13:39:08 -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=tzpbbzIX; 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 S1752720AbeC3Uh1 (ORCPT + 99 others); Fri, 30 Mar 2018 16:37:27 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:35641 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752206AbeC3Uh0 (ORCPT ); Fri, 30 Mar 2018 16:37:26 -0400 Received: by mail-io0-f194.google.com with SMTP id x77so5869026ioi.2 for ; Fri, 30 Mar 2018 13:37:26 -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=wMrNzl/VuGrnW12NVUE1/6AZFoyqXR4UAHbZR6LERHE=; b=tzpbbzIXwhvkA0QuWq3+9sEtUibk2DuMSxCxr85R3TrBk5UrZ79khz4mwNCWfkIAAW PV//Hh9JHOtQyVPV36oKHxXP5sigSItjbf33J7C52tBIndpENCEuWd2cHW7BaEOMrlu4 JXRuEADrPNLnzSNuxxTf2vmEebolChm/2DgrQiXO1Vvgo+rwdYuLcaQ/XMyVCsf2USJ2 xuqgR7zwoj1p9lC/1q8Qy4LXgj1J4vwM+1Zn/bq3JtY8KC8s7MqdGXBQeP9iG7eZuOKL cLDeLid75UVHY5hfQgtl72DpAfwdJEdq2sNhY+g/Vmdbx1dEIaZW68AsGl6DRfCrrHNT T/SQ== 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=wMrNzl/VuGrnW12NVUE1/6AZFoyqXR4UAHbZR6LERHE=; b=H9pp3S9caDQ5AB7tDqPmxOqoinl1BCdXt7cU9rWopyK9WliXcHNGpqCJRZw0HhWPHQ WNx/uUjyL+Uj0P8wxFKpPLz8WeOu8C11s7De18VoG94BYWQ4ic3xqlhs4TRiHj4u3v7h 6cTLzAEdR5Z1aY8/pUw+ZhXvdb/GuEZVn4Bg9kPe+FSk3Rqp3jY7LmGpxINrCjts2+G4 KLsxcCTBry8wfX4w0/m0RMknNdSN4JXsA7BOnB9pp9yVMV/jqiUSDd+FAJV7+wxaOq3P LooXFoeW0jh07t3QwcMSzdMFcwGbkJmx0Tma7Kf3GyIlACgCoJW7KywQIY1VmZQOGGhG Uyyg== X-Gm-Message-State: ALQs6tDGhFmgakdCKlKZZsvl5akoGmWrtF5vEv2q/HGpbw9AZz08cQGr U4qZPqiODwD30AR8O7G5ckcOeMQVcvVxDjfktc97fA== X-Received: by 10.107.19.83 with SMTP id b80mr442241ioj.251.1522442245008; Fri, 30 Mar 2018 13:37:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.11.158 with HTTP; Fri, 30 Mar 2018 13:37:24 -0700 (PDT) In-Reply-To: <20180330151037.30d2ac6d@gandalf.local.home> References: <1522320104-6573-1-git-send-email-zhaoyang.huang@spreadtrum.com> <20180330102038.2378925b@gandalf.local.home> <20180330151037.30d2ac6d@gandalf.local.home> From: Joel Fernandes Date: Fri, 30 Mar 2018 13:37:24 -0700 Message-ID: Subject: Re: [PATCH v1] kernel/trace:check the val against the available mem To: Steven Rostedt Cc: Zhaoyang Huang , Ingo Molnar , LKML , kernel-patch-test@lists.linaro.org, Andrew Morton , Michal Hocko , "open list:MEMORY MANAGEMENT" , Vlastimil Babka , Michal Hocko 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 Fri, Mar 30, 2018 at 12:10 PM, Steven Rostedt wrote: [..] >> > I wonder if I should have the ring buffer allocate groups of pages, to >> > avoid this. Or try to allocate with NORETRY, one page at a time, and >> > when that fails, allocate groups of pages with RETRY_MAYFAIL, and that >> > may keep it from causing an OOM? >> > >> >> I don't see immediately how that can prevent an OOM in other >> applications here? If ftrace allocates lots of memory with >> RETRY_MAYFAIL, then we would still OOM in other applications if memory >> isn't available. Sorry if I missed something. > > Here's the idea. > > Allocate one page at a time with NORETRY. If that fails, then allocate > larger amounts (higher order of pages) with RETRY_MAYFAIL. Then if it > can't get all the memory it needs, it wont take up all memory in the > system before it finds out that it can't have any more. > > Or perhaps the memory management system can provide a > get_available_mem() function that ftrace could call before it tries to > increase the ring buffer and take up all the memory of the system > before it realizes that it can't get all the memory it wants. > > The main problem I have with Zhaoyang's patch is that > get_available_mem() does not belong in the tracing code. It should be > something that the mm subsystem provides. > Cool. Personally I like the getting of available memory solution and use that, since its simpler. MM already provides it through si_mem_available since the commit "mm/page_alloc.c: calculate 'available' memory in a separate function" (sha d02bd27b). Maybe we could just use that? MemAvailable was initially added in commit "/proc/meminfo: provide estimated available memory" (sha 34e431b0ae39) thanks, - Joel