From patchwork Sat Jun 2 11:58:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?56a56Iif6ZSu?= X-Patchwork-Id: 10444781 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 4DBEE60375 for ; Sat, 2 Jun 2018 11:59:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F83D28A67 for ; Sat, 2 Jun 2018 11:59:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3413A28A6A; Sat, 2 Jun 2018 11:59:42 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB31528A67 for ; Sat, 2 Jun 2018 11:59:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B47F6B0007; Sat, 2 Jun 2018 07:59:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 861E56B0008; Sat, 2 Jun 2018 07:59:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7519A6B000A; Sat, 2 Jun 2018 07:59:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 31AC16B0007 for ; Sat, 2 Jun 2018 07:59:40 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id y21-v6so2323677pfm.4 for ; Sat, 02 Jun 2018 04:59:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=tVwHDyE4u8qGm3FbAMqQA8kY26gjDGUXcIX4LM/uoP4=; b=Zgr+E/ZIfdFG0OUGsdjfPSr30iroJvVcwPe4OiV0iwIehmlXOE24WHJo6dKeJCfLQv +FZYVDdwR6THzkARjYIoqHRsOlmoOm3SQF7Cv2mcoMtu7WU7nog/X8EE2UIQps/EZE7S YzpXxdUNqbRuCCBgzA0sYkQ5RrU1jnYg2GMBP4ZRFx8Z2rXF1bf1JclcROBaedqtjg6u BVOuRj+hhlpvy8JCUzAyYLIHNVexSVPfmsSLcrjsiD7P/X1+m05JXQbfZj8kXjiXYtWl Szv7lWZDQ/7pKyv1DhgDVtmbvm+OQ7jqbkHMEL6FpdxPmFwiTrxVGmiNgpXifI8DinxR ukkQ== X-Gm-Message-State: APt69E0sDneFLM7fVSre9dcAyN0F+JE/syk4yznimF96RwYIKk0gmZKG 8cYrovoPq7bWGaGsbz61e2oFX+luwvexfUmq/uXNqRWkJLwKu/VN0111zzCUDGSKq/kbnsSh3yU QTGijlPp8D0pK7AXm/bGyfBEn4iH1yI2XGrq+eBssxuTsUX4/6y91NKCHj6TiGl+/Oc9FmV2eSU yA9QvKb96JiWy3jT48mwUZUbOWqdENRYDN1oDZjGCys22QA2Akgz/HVWmoTx1cOTkCRYTP+bGmq hIklBr+plZaRGv99WlDycE61xT7U8aQww30Ag7CoRuiCcaMY+DLl2MWZh1t7i9ihm4/e9w71qiu C/hQjLBgxQyLtTiiMrjEQrv7nYZ374TSa3k/kolfvPKEcOYKDlTHB3n+Tx5q0ZnqsNVVmf0j4X8 M X-Received: by 2002:a17:902:5409:: with SMTP id d9-v6mr3137406pli.0.1527940779910; Sat, 02 Jun 2018 04:59:39 -0700 (PDT) X-Received: by 2002:a17:902:5409:: with SMTP id d9-v6mr3137380pli.0.1527940779386; Sat, 02 Jun 2018 04:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527940779; cv=none; d=google.com; s=arc-20160816; b=hqbagP+mi43nUq/7AxiThOVCzp/ALuyb1lbijrLG49q4NnudVHNrD+cYU6ZOWIWGau dodulfp/PfFBJeJPqc2Q2JdTMMoPUxutH8YFkZSGRiicSHQ/VuRfKVPXZAmg+xPbvvPb nIuIgDgTyS7FOMH5O4uHQRsTkS8/4twV5XRlmKQHAt05JxFdG+bltLi7f6MO4TblxnN8 qphKsVDUDeMR4glEp+qEVAtGyixH2k/dSdTDc8iULj9brEgmCe0reJFmAnDdURfoMId/ TkGvejxHrxAdWuPE6g+sOXwanPeVYwpCHHokn1PtiXWYYnT5IkWUHTgQ2Y0nDROcCkFx M4IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=tVwHDyE4u8qGm3FbAMqQA8kY26gjDGUXcIX4LM/uoP4=; b=y8SBzEqWG5+I65voNGXk4Thr+jV3R73FrorLfYfgYGSNgxMa8uY8jo8F+/RBZwgSeK JuOi4brBrxVe7Q4Ac3DDuB+cI1HXzdWUUpupHRvxLERzCzKD6qVMSXss7YMCDPW75ygf UCWv7nAmhNTOa5nVKhLLh0yYc5b3cF8uBVYQSEGXR5qIbLJCmK8dVfM8NYloRdb4l2D6 Akxk3oA2TDqONZv+RIz6rOB08uVmCszwKgagORlCsGwnJ0X2Ccj5Q9/RHJrxIRitoqGB 3vm5YexFIZs2LvPoeNDALw3DMNmlRPtGU0vsIgjWlsUwXPofFefqnwZSBipBPEYYK5yD PVxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NkvWcjjF; spf=pass (google.com: domain of ufo19890607@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ufo19890607@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y67-v6sor14632147pff.127.2018.06.02.04.59.39 for (Google Transport Security); Sat, 02 Jun 2018 04:59:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ufo19890607@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NkvWcjjF; spf=pass (google.com: domain of ufo19890607@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=ufo19890607@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tVwHDyE4u8qGm3FbAMqQA8kY26gjDGUXcIX4LM/uoP4=; b=NkvWcjjFPGLvSmIosm4GibhiPoyjeRZoWG61lXyUeBxoMguYWO9VGJdDBjE74fU0Lt s2PziUEGrvX77kZEvJiTxXMhm+K745nxnlKTFgcJI8UUYtb0GmMOCPf9qemuOpEQJ6h6 BSdCQQbUzzmiHHdzpkCy8vP+jYnbt9Q18o9rSV3o8vSoPJXbnVRBrxcgL9gjRCLjTFjR 2t5S5GoxfG3tO+yNNEsmC75hHgW7FkkkCje7PmalvJXkmMPkG9ckzko/K7mzOp7bVju6 6wkhmteW2hON0dY7qasma6LazhwtC3i2nZuFQdKPj3S1GYhhTuBW30/a/J5Om3V6wexD lnog== X-Google-Smtp-Source: ADUXVKJSJlF83yhGnDX4v5YoT+wHDiCPR92qIHg2wqBcN9YpRFDOsjVvH8CvkcxZWw+1GZMLzlD52Q== X-Received: by 2002:a63:3348:: with SMTP id z69-v6mr8215732pgz.171.1527940779179; Sat, 02 Jun 2018 04:59:39 -0700 (PDT) Received: from dest.didichuxing.com ([52.229.160.192]) by smtp.gmail.com with ESMTPSA id c83-v6sm84723543pfc.111.2018.06.02.04.59.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 04:59:38 -0700 (PDT) From: ufo19890607@gmail.com To: akpm@linux-foundation.org, mhocko@suse.com, rientjes@google.com, kirill.shutemov@linux.intel.com, aarcange@redhat.com, penguin-kernel@I-love.SAKURA.ne.jp, guro@fb.com, yang.s@alibaba-inc.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yuzhoujian Subject: [PATCH v7 1/2] Add an array of const char and enum oom_constraint in memcontrol.h Date: Sat, 2 Jun 2018 19:58:53 +0800 Message-Id: <1527940734-35161-3-git-send-email-ufo19890607@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527940734-35161-1-git-send-email-ufo19890607@gmail.com> References: <1527940734-35161-1-git-send-email-ufo19890607@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: yuzhoujian This patch will make some preparation for the follow-up patch: Refactor part of the oom report in dump_header. It puts enum oom_constraint in memcontrol.h and adds an array of const char for each constraint. Signed-off-by: yuzhoujian --- include/linux/memcontrol.h | 14 ++++++++++++++ mm/oom_kill.c | 7 ------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index d99b71bc2c66..57311b6c4d67 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -62,6 +62,20 @@ struct mem_cgroup_reclaim_cookie { unsigned int generation; }; +enum oom_constraint { + CONSTRAINT_NONE, + CONSTRAINT_CPUSET, + CONSTRAINT_MEMORY_POLICY, + CONSTRAINT_MEMCG, +}; + +static const char * const oom_constraint_text[] = { + [CONSTRAINT_NONE] = "CONSTRAINT_NONE", + [CONSTRAINT_CPUSET] = "CONSTRAINT_CPUSET", + [CONSTRAINT_MEMORY_POLICY] = "CONSTRAINT_MEMORY_POLICY", + [CONSTRAINT_MEMCG] = "CONSTRAINT_MEMCG", +}; + #ifdef CONFIG_MEMCG #define MEM_CGROUP_ID_SHIFT 16 diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 8ba6cb88cf58..c806cd656af6 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -237,13 +237,6 @@ unsigned long oom_badness(struct task_struct *p, struct mem_cgroup *memcg, return points > 0 ? points : 1; } -enum oom_constraint { - CONSTRAINT_NONE, - CONSTRAINT_CPUSET, - CONSTRAINT_MEMORY_POLICY, - CONSTRAINT_MEMCG, -}; - /* * Determine the type of allocation constraint. */