Received: by 10.213.65.68 with SMTP id h4csp804002imn; Wed, 4 Apr 2018 07:33:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/c4tUVHGc0DkuRDOfQRzmXmz74JSYw/QXtC2t6UQovZrqCqMBdrEQqNaoYbtAlIvPFdy4j X-Received: by 2002:a17:902:4001:: with SMTP id b1-v6mr18598095pld.273.1522852405469; Wed, 04 Apr 2018 07:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522852405; cv=none; d=google.com; s=arc-20160816; b=XOxVT9+HHg9Yq6u0k4gOII2bowRr50pbFZSYkv9vY/4Xf0SAhkKzMqvdT5/Xz9+sYk Slj2ihm/jYgRhhAQmFMF5UaqspGUne6abU3zuaMvcaVbbyd6LU0xih0mHs6c2vHlo2B2 sKZpr9g4nspJ9ameWHluwSTQcXalx+Ls+9OSoAD4Ihd9J2k9Rlw2HCLciOOFn7LE5UgG e2xBDWFZ/t6kuFn3OnWT4RdF8Bloj27ysKF0wZPglZfzlpZPhP3suvoh/wpzaK60BX2D mGhgNOj9GbRHd3g9il965kLFishOFw6k5JGx8Gq+4xoCFq44d2r93hcA51I86Q9JyVgP o7EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=ZSUS62JAyHIKVeIFdJ2fnViM3n58CI13lfqEeBO5bkQ=; b=nvMVfxvWdTEaN/lOj55WytHBQbejLmQLOKXmViLCUuD1/212xkkBxM0sPmx316LVIA 2RHpZpGG1pmII0esku6v8MjEW1otgovfqO1+cZbcoTcaVp736b09voXPGkZyVlXQj4/3 Ldsp1MppgEyL81CA3Y5+84kFG2ZPi/0FwuwHIM7cQg0QemYheuebLoioDKPvfTRGRE6C aNArurAtBYHjJ5FfNs3VB6acQwogY7yJ1U/IoCJqpzYRXoH97OqPFoe4rrSgl6+pGTq7 U+G4aDvLlRf2XhJTJHH/KPr2Mi2IXYlhI+Y5NCiPU8KhRkRwwEN2DD0daot9YpVK+GW1 EZPw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p64si4141924pfd.393.2018.04.04.07.33.10; Wed, 04 Apr 2018 07:33:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751417AbeDDObP (ORCPT + 99 others); Wed, 4 Apr 2018 10:31:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:42906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751167AbeDDObO (ORCPT ); Wed, 4 Apr 2018 10:31:14 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4799B21707; Wed, 4 Apr 2018 14:31:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4799B21707 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Wed, 4 Apr 2018 10:31:11 -0400 From: Steven Rostedt To: Michal Hocko Cc: Zhaoyang Huang , Ingo Molnar , linux-kernel@vger.kernel.org, kernel-patch-test@lists.linaro.org, Andrew Morton , Joel Fernandes , linux-mm@kvack.org, Vlastimil Babka Subject: Re: [PATCH v1] kernel/trace:check the val against the available mem Message-ID: <20180404103111.2ea16efa@gandalf.local.home> In-Reply-To: <20180404142329.GI6312@dhcp22.suse.cz> References: <20180403110612.GM5501@dhcp22.suse.cz> <20180403075158.0c0a2795@gandalf.local.home> <20180403121614.GV5501@dhcp22.suse.cz> <20180403082348.28cd3c1c@gandalf.local.home> <20180403123514.GX5501@dhcp22.suse.cz> <20180403093245.43e7e77c@gandalf.local.home> <20180403135607.GC5501@dhcp22.suse.cz> <20180404062340.GD6312@dhcp22.suse.cz> <20180404101149.08f6f881@gandalf.local.home> <20180404142329.GI6312@dhcp22.suse.cz> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 4 Apr 2018 16:23:29 +0200 Michal Hocko wrote: > On Wed 04-04-18 10:11:49, Steven Rostedt wrote: > > On Wed, 4 Apr 2018 08:23:40 +0200 > > Michal Hocko wrote: > > > > > If you are afraid of that then you can have a look at {set,clear}_current_oom_origin() > > > which will automatically select the current process as an oom victim and > > > kill it. > > > > Would it even receive the signal? Does alloc_pages_node() even respond > > to signals? Because the OOM happens while the allocation loop is > > running. > > Well, you would need to do something like: > > > > > I tried it out, I did the following: > > > > set_current_oom_origin(); > > for (i = 0; i < nr_pages; i++) { > > struct page *page; > > /* > > * __GFP_RETRY_MAYFAIL flag makes sure that the allocation fails > > * gracefully without invoking oom-killer and the system is not > > * destabilized. > > */ > > bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()), > > GFP_KERNEL | __GFP_RETRY_MAYFAIL, > > cpu_to_node(cpu)); > > if (!bpage) > > goto free_pages; > > > > list_add(&bpage->list, pages); > > > > page = alloc_pages_node(cpu_to_node(cpu), > > GFP_KERNEL | __GFP_RETRY_MAYFAIL, 0); > > if (!page) > > goto free_pages; > > if (fatal_signal_pending()) > fgoto free_pages; But wouldn't page be NULL in this case? > > > bpage->page = page_address(page); > > rb_init_page(bpage->page); > > } > > clear_current_oom_origin(); > > If you use __GFP_RETRY_MAYFAIL it would have to be somedy else to > trigger the OOM killer and this user context would get killed. If you > drop __GFP_RETRY_MAYFAIL it would be this context to trigger the OOM but > it would still be the selected victim. Then we guarantee to kill the process instead of just sending a -ENOMEM, which would change user space ABI, and is a NO NO. Ideally, we want to avoid an OOM. I could add the above as well, when si_mem_avaiable() returns something that is greater than what is available, and at least this is the process that will get the OOM if it fails to allocate. Would that work for you? -- Steve