From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755092AbcLPRXM (ORCPT ); Fri, 16 Dec 2016 12:23:12 -0500 Received: from mga01.intel.com ([192.55.52.88]:39739 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753930AbcLPRXF (ORCPT ); Fri, 16 Dec 2016 12:23:05 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,358,1477983600"; d="scan'208";a="19051742" From: "Xiong, Jinshan" To: Joe Perches CC: Tabrez khan , "Dilger, Andreas" , "jsimmons@infradead.org" , "devel@driverdev.osuosl.org" , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "lustre-devel@lists.lustre.org" Subject: Re: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. Thread-Topic: [lustre-devel] [PATCH] staging : lustre : Remove braces from single-line body. Thread-Index: AQHSV8EOnZx9zBFGTkKf6pk9ll9cMA== Date: Fri, 16 Dec 2016 17:23:03 +0000 Message-ID: References: <1481898571-16842-1-git-send-email-khan.tabrez21@gmail.com> <1481904353.29291.87.camel@perches.com> In-Reply-To: <1481904353.29291.87.camel@perches.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.182.99] Content-Type: text/plain; charset="utf-8" Content-ID: <8A7C6DB3686A9241AAD28059B221CEC1@intel.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id uBGHNGvK011924 > On Dec 16, 2016, at 8:05 AM, Joe Perches wrote: > > On Fri, 2016-12-16 at 19:59 +0530, Tabrez khan wrote: >> Remove unnecessary braces {} for single while statement. > > Your patch is fine Tabrez, but to the lustre folk: > >> diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c > [] >> @@ -1371,9 +1371,9 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, > LASSERT(atomic_read(&anchor->csi_sync_nr) == 0); > > /* wait until cl_sync_io_note() has done wakeup */ > - while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) { > + while (unlikely(atomic_read(&anchor->csi_barrier) != 0)) > cpu_relax(); > - } > + > > What if the wakeup never occurs/succeeds? > Should there be a timeout? There is no wakeup at all. This piece of code is to solve the preempting race condition in cl_sync_io_end(), where it calls wake_up_all() to wake up the cl_sync_io_wait() process, and then is preempted _inside_ wake_up_all(), and then cl_sync_io_wait() process gains the CPU and frees memory cl_sync_io. Therefore when cl_sync_io_end() comes back to finish its work in wake_up_all(), a piece of freed memory will be accessed. csi_barrier is proposed to solve this problem, which makes sure wake_up_all() is complete before cl_sync_io_wait() can continue. It should be a really short time so it’s reasonable for cl_sync_io_wait() to do a busy loop wait. Jinshan > _______________________________________________ > lustre-devel mailing list > lustre-devel@lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org