Path: csiph.com!aioe.org!bofh.it!news.nic.it!robomod From: Michal Hocko Newsgroups: linux.kernel Subject: Re: [PATCH 03/10] proc, oom_adj: extract oom_score_adj setting into a helper Date: Tue, 21 Jun 2016 14:20:01 +0200 Message-ID: References: X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/0ReyVMUpS2icIzq/uavVHUVMdKro5juI9ueNvXoo54=; b=mjJr8ypRNlghxfAVdXLgO/zng9Guyqc4PyFEHLBv252NASufs5XDO5LfJA6Hzzwac0 fb9oAVJatYLd9agLWmJiDnqpkzMTLBaIu6jWaHmxPTiR4adjHLZFGWU3jzsEXOa14T7L 2rdDSYUgkLEQicWRg+h9M23mfGA4CsmpROEEhbS/pUdAVPYtwGOlW98QAaVO6IsIpbEI b/gsR2SVnpbPiadTXtqflrUFdsOQ7x046Lxk3tnsAdrLF+v++EnsHc1C5bxK6m2TKjJg kk1XIJqOsyH+DbrbAfoyPZiWTr/zvMQhVeOpZLWmRMeLAgdu9rUEV9JnK3ivIrQvalzs a+Rw== X-Gm-Message-State: ALyK8tIlnd42yLxhuVNnFEXIr7D04ANGwa0ZNjYMsF03yYoVY+WKPoOIc7/Q037atX3L3A== X-Received: by 10.194.159.98 with SMTP id xb2mr21453387wjb.29.1466507838918; Tue, 21 Jun 2016 04:17:18 -0700 (PDT) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 40 Organization: linux.* mail to news gateway X-Original-Cc: 'Oleg Nesterov' , linux-kernel , linux-mm@kvack.org X-Original-Date: Tue, 21 Jun 2016 13:17:16 +0200 X-Original-Message-ID: <20160621111716.GD30848@dhcp22.suse.cz> X-Original-References: <06be01d1cb9c$8f235850$ad6a08f0$@alibaba-inc.com> <06bf01d1cb9f$32a49320$97edb960$@alibaba-inc.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1427693 On Tue 21-06-16 17:27:57, Hillf Danton wrote: > > > > From: Michal Hocko > > > > Currently we have two proc interfaces to set oom_score_adj. The legacy > > /proc//oom_adj and /proc//oom_score_adj which both have their > > specific handlers. Big part of the logic is duplicated so extract the > > common code into __set_oom_adj helper. Legacy knob still expects some > > details slightly different so make sure those are handled same way - e.g. > > the legacy mode ignores oom_score_adj_min and it warns about the usage. > > > > This patch shouldn't introduce any functional changes. > > > > Acked-by: Oleg Nesterov > > Signed-off-by: Michal Hocko > > --- > > fs/proc/base.c | 94 +++++++++++++++++++++++++++------------------------------- > > 1 file changed, 43 insertions(+), 51 deletions(-) > > > > diff --git a/fs/proc/base.c b/fs/proc/base.c > > index 968d5ea06e62..a6a8fbdd5a1b 100644 > > --- a/fs/proc/base.c > > +++ b/fs/proc/base.c > > @@ -1037,7 +1037,47 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count, > > return simple_read_from_buffer(buf, count, ppos, buffer, len); > > } > > > > -static DEFINE_MUTEX(oom_adj_mutex); > > +static int __set_oom_adj(struct file *file, int oom_adj, bool legacy) > > +{ > > + static DEFINE_MUTEX(oom_adj_mutex); > > Writers are not excluded for readers! > Is this a hot path? I am not sure I follow you question. This is a write path... Who would be the reader? -- Michal Hocko SUSE Labs