Received: by 10.213.65.68 with SMTP id h4csp2191336imn; Thu, 29 Mar 2018 20:33:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/blF5jEBu76+hzjZPm2GNh/1yjX6Ib9TcnQxY4RH9mCrX1nTYWP9beenAqR3uPvVy7RMo9 X-Received: by 10.99.112.84 with SMTP id a20mr2998981pgn.253.1522380823967; Thu, 29 Mar 2018 20:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522380823; cv=none; d=google.com; s=arc-20160816; b=LbPO8UcTqr1O5MgKcMKPJ+VmES9/zhKj1oqv51vFP7CbxShmDMI2eBNEphjChQxqNs WlOmGae1QF7vtJejdaPhHIxFNSRO6haN7jaeiyANTLXxGpGjskfeLd2n+vqx8Mc0SSlc s15sgZb6lcR1RrirpTfdb72GHDmU62ViV118LayV7sKgOWKTdJG7Qk9unEEboh6ts4hZ nKx0Y7rP48NEZ9e0hqjnQJZwveXTaA1OJVmkRg2QQgdwm9F3F9ZZW5sMw0OQ7bwOGVOj 4SmpTBo2qgxfNK1opP2YK0B+wQK/UHQJPR83djowDPL3osgr4EF0w/esGHiAVmEsu9u4 nsCg== 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=XyaPARdYrH3quh0R9ezO0Uus3pjPeiyeQyU+dZAvzB0=; b=UpOM8amNoWCJuoDJrUjptmSKH3zf7slZJnHNDpGZC95x1QJk8klKxOF18BRS1MxbLF WY9w1JNZGVYIuNAu0aTH4KZOO5IHw1+ULXxcX3QdEyULylfnG4mGlP0qDlPb9q8yoIcV 2xfGOeejY+wm+gFNYSMlFJJB0kc9zkV8v7la6BOEh+KTxsLeiV1Eq7G0r3Ubd3QPeJnv fp16uLiLUI7aoEfOV1ksqnnYJoB1F1MLSsZBgZN4fdvrYsFNLZeqd+ZCyZhFaNun5lst d90KdcjTLoC1qB0WtN/sS7Eu7Acl8DT7g5krXqz+qv38KhEknHLPG5Ag2y0ZJJrcN5sQ FITw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ma22v5eY; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16-v6si7121187plp.621.2018.03.29.20.33.30; Thu, 29 Mar 2018 20:33:43 -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=@gmail.com header.s=20161025 header.b=Ma22v5eY; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752744AbeC3DcZ (ORCPT + 99 others); Thu, 29 Mar 2018 23:32:25 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53281 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752487AbeC3DcY (ORCPT ); Thu, 29 Mar 2018 23:32:24 -0400 Received: by mail-wm0-f68.google.com with SMTP id p9so13707706wmc.3 for ; Thu, 29 Mar 2018 20:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=XyaPARdYrH3quh0R9ezO0Uus3pjPeiyeQyU+dZAvzB0=; b=Ma22v5eYGiScjD1jMh55FzHQzxieHOFeYCMhvmaHjRYlIJI1n096OO+ECs6GprGXg7 7aHG4nGIzZF5b2Zp3YH4ly60RMJz2WRUZ6hpBX3OTaqxYnMOKp7UNsCoQQbAXv7oMtL8 FegoBGUCwhtuhESXKRXtC7+aBdF1uL5/7ybefNGrnplP76/0D2NW7TBFgzaFtIfZ8NzE msyiG+5kPFBsaAC8Z9Qs+u2VrIKtZpztLw0m2a8lDQyCKUtanZgHDBXE71Credv/zmpf 0eeoN3SfXV7wfiiiKUnOQWAmlKzttdrAhnZGm6FXklV4ERQRF5a4tsDS0SdD6FweGsRL HC3A== 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=XyaPARdYrH3quh0R9ezO0Uus3pjPeiyeQyU+dZAvzB0=; b=r8T7gLZlCsL7rjlg5n65y0Fy7RK4+aydqPNyqXb/Qv/2rT3SUB4130pGlmDIq73T4k bHGfvLy5qnqzaAQuz9RinBN5HhgNLOXtV7IwV/IYKJGZSOExRryL5N0JqhZ59nlOy+az LMJF5MV6JJPf1DaUEaN24yPPrKBvPzkjmVfwhBIB+I5d9INfiG35pSfBnTikjFxXAXD2 CcWN/jgM/mYnX2kR7uknK0ckj5P80lemXas5Ym5hVmaTRK8ONmXCeAj0ZKXkexRtQ/Lk yIFYn8rTNKFadXejRHx4GN9K/sxoYSdSOIEUa1WYWdipn9cFgLn+hb60LEYWnmUGqJjT nLEA== X-Gm-Message-State: AElRT7FCA5NTPoUgMtrVNi6OmeOZQ7PZ4eL+vOk0LZnM2cZfwKstPvBS TJyI5PbWKRWx90l7KIY+bzy77++vn4Z1DbdBRz0= X-Received: by 10.80.139.141 with SMTP id m13mr1255743edm.164.1522380743185; Thu, 29 Mar 2018 20:32:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.201.76 with HTTP; Thu, 29 Mar 2018 20:32:22 -0700 (PDT) In-Reply-To: <20180329120528.337bf6cb@gandalf.local.home> References: <1522320104-6573-1-git-send-email-zhaoyang.huang@spreadtrum.com> <20180329120528.337bf6cb@gandalf.local.home> From: Zhaoyang Huang Date: Fri, 30 Mar 2018 11:32:22 +0800 Message-ID: Subject: Re: [PATCH v1] kernel/trace:check the val against the available mem To: Steven Rostedt Cc: Ingo Molnar , linux-kernel@vger.kernel.org, kernel-patch-test@lists.linaro.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 On Fri, Mar 30, 2018 at 12:05 AM, Steven Rostedt wrote: > On Thu, 29 Mar 2018 18:41:44 +0800 > Zhaoyang Huang wrote: > >> It is reported that some user app would like to echo a huge >> number to "/sys/kernel/debug/tracing/buffer_size_kb" regardless >> of the available memory, which will cause the coinstantaneous >> page allocation failed and introduce OOM. The commit checking the >> val against the available mem first to avoid the consequence allocation. >> > > One of my tests is to stress buffer_size_kb, and it fails nicely if you > try to get too much. Although, it may cause an OOM, but that's expected. > > The application should do the test (try "free" on the command line). > This isn't something that the kernel should be responsible for. If > someone wants to allocate all memory for tracing, that's their > prerogative. > > -- Steve Steve, thanks for your quick feedback. The original purpose is to avoid such kind of OOM as kernel can not define the behavior of the application. I think it is no need to do the alloc->free process if we have known the number of pages difinitly lead to failure. Furthermore, the app which screw up the thing usually escape the OOM and cause the innocent to be sacrificed.