From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C659AC33C9E for ; Tue, 7 Jan 2020 02:07:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8A4E520715 for ; Tue, 7 Jan 2020 02:07:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sTFeI61t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A4E520715 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 15A428E000F; Mon, 6 Jan 2020 21:07:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10B208E0001; Mon, 6 Jan 2020 21:07:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3B3F8E000F; Mon, 6 Jan 2020 21:07:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id DA4308E0001 for ; Mon, 6 Jan 2020 21:07:32 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 7121A824999B for ; Tue, 7 Jan 2020 02:07:32 +0000 (UTC) X-FDA: 76349201544.20.cloth12_7bfadb2458e19 X-HE-Tag: cloth12_7bfadb2458e19 X-Filterd-Recvd-Size: 4506 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jan 2020 02:07:31 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id b22so22546359pls.12 for ; Mon, 06 Jan 2020 18:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=FcqVbuH4BEZl+ciRs0e0B8iPKj0+hshWElohx4nDlP8=; b=sTFeI61tYPfuAIi6zuNSHzccw82y+IFJQZN/FOERtaSSqtpiXv2rOpO1dyPm4suK9d ftLYzVvf4icX0o3N0u/z5HFcxiat1L2XRuge1iX7lbBY2Md2XAs+Vxt04yEGQu7uv2l8 B9lrwHI36DRK0JUm1QxdEBLBDZl4WkM/Ai4x6+Hqh019u9drIfYC7rQPYih72eXUlL7V KOFBxa2toSREPK7LfZYoSs+/8fgvnWy7jTYEu1twlyKcjKroHFNdQjabRMii/TID8Eev FBntvssn6jwCDIMA8zHiVazWzc611aei+IvMD9PvhSF9GrFnfsLNykTivOxhqLapB3+P +P0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=FcqVbuH4BEZl+ciRs0e0B8iPKj0+hshWElohx4nDlP8=; b=NdNeWPSIDPhC+ZWBvjNQmBifllNOWMz++QGGku7sg+IyZIbFf469qFLnjg+flZhTMZ PrErkuGsF03b+3oa8jXgc0Xkq/qIifJ21PwRMQHuio5sEBYp/+HgsVrtlJmOraDBsopA jo8QLQh7iml1lELMhjJiUX95BAHZ47aLBKgS3DHACc1aR9cVjWLhN0mvUR0v+SkCn8EX AbqNevYiKdeTBluGb2XLOzeaw2anOVOEFWJ9v1t3Jyf01Am3NathuNXI0jHI/JIrauJy exDZbkun8PWLMQRcH5UFeqhqRRHeb4PDTilm3ih9BVvLayz5+/xbO7IVyFQjmOTjxvxl O0Yg== X-Gm-Message-State: APjAAAVX4PdopdZgUwo7D4kBl+tk+cAfzRYdCgBO2NN83e1WRfGM8cJa BudtzpRwQXc9at9gaHbfux2iEQ== X-Google-Smtp-Source: APXvYqxSmH3jtb3yGf6lQzuN/p1hBfhYZSwhFc2W7ST0vDRyyIEI7Z+ED8qhCWhzRta6FDHArc60zA== X-Received: by 2002:a17:90a:660b:: with SMTP id l11mr45934270pjj.47.1578362850725; Mon, 06 Jan 2020 18:07:30 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id i3sm78670353pfg.94.2020.01.06.18.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 18:07:29 -0800 (PST) Date: Mon, 6 Jan 2020 18:07:29 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Wei Yang cc: Alexander Duyck , Johannes Weiner , Michal Hocko , vdavydov.dev@gmail.com, Andrew Morton , "Kirill A. Shutemov" , cgroups@vger.kernel.org, linux-mm , LKML , Yang Shi Subject: Re: [RFC PATCH] mm: thp: grab the lock before manipulation defer list In-Reply-To: <20200107012624.GB15341@richard> Message-ID: References: <20200103143407.1089-1-richardw.yang@linux.intel.com> <20200107012624.GB15341@richard> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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: On Tue, 7 Jan 2020, Wei Yang wrote: > >One thing you might want to do is pull the "if (compound)" check out > >and place it outside of the spinlock check. It would then simplify > >this signficantly so it is something like > >if (compound) { > > spin_lock(); > > list = page_deferred_list(page); > > if (!list_empty(list)) { > > list_del_init(list); > > from->..split_queue_len--; > > } > > spin_unlock(); > >} > > > >Same for the block below. I would pull the check for compound outside > >of the spinlock call since it is a value that shouldn't change and > >would eliminate an unnecessary lock in the non-compound case. > > This is reasonable, if no objection from others, I would change this in v2. Looks fine to me; I don't see it as a necessary improvement but there's also no reason to object to it. It's definitely a patch that is needed, however, for the simple reason that with the existing code we can manipulate the deferred split queue incorrectly so either way works for me. Feel free to keep my acked-by.