From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751896AbcFVDSY (ORCPT ); Tue, 21 Jun 2016 23:18:24 -0400 Received: from out4133-66.mail.aliyun.com ([42.120.133.66]:20938 "EHLO out4133-66.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751774AbcFVDSX (ORCPT ); Tue, 21 Jun 2016 23:18:23 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R491e4;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e02c03310;MF=hillf.zj@alibaba-inc.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_----4x34vdD_1466565432; Reply-To: "Hillf Danton" From: "Hillf Danton" To: "'Michal Hocko'" Cc: "'Oleg Nesterov'" , "'linux-kernel'" , References: <06be01d1cb9c$8f235850$ad6a08f0$@alibaba-inc.com> <06bf01d1cb9f$32a49320$97edb960$@alibaba-inc.com> <20160621111716.GD30848@dhcp22.suse.cz> In-Reply-To: <20160621111716.GD30848@dhcp22.suse.cz> Subject: Re: [PATCH 03/10] proc, oom_adj: extract oom_score_adj setting into a helper Date: Wed, 22 Jun 2016 11:17:12 +0800 Message-ID: <06e801d1cc34$920d5cd0$b6281670$@alibaba-inc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQIyWb/3a0/9cuSb2i9D7m6Wp+9qVgIW1PdZAYFnVrGfFuwyoA== Content-Language: zh-cn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > 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? > Currently oom_adj_read() and oom_adj_write() are serialized with task->sighand->siglock, and in this work oom_adj_mutex is introduced to only keep writers in hose. Plus, oom_adj_write() and oom_badness() are currently serialized with task->alloc_lock, and they may be handled in subsequent patches. thanks Hillf