Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4265936imm; Mon, 6 Aug 2018 21:20:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeBh+F+R8i5POwHc7Ss8zx+7YGwrO0tkbBHQbr4DgCZX8S6UHebjZDTZotW1I9dfCMxNsV1 X-Received: by 2002:a62:3306:: with SMTP id z6-v6mr19519549pfz.85.1533615601095; Mon, 06 Aug 2018 21:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533615601; cv=none; d=google.com; s=arc-20160816; b=TuZ44tliBP6eauMvABE6n6CGuhVCcUOhyw1PXoTpTNCVOW/Bl0lKI+UNJ1VGiOzURO K4k5yDciV46aCA5izmQY1HPVPCKXscEcg7JfRVHyEAxyT9OAzMlr00pmPfCOP7bUuScO JqOno5r9UOiNjLsCmYqAWnB7lwksZgU/q5WtqTNUWYUQ3U6bnmnuP0l1cJYryckD1ef2 Erx8IaP7Zad5gUP0Eg5tmWhOCB6B3pJrVhrSCoDTz2a1oOMYO2UGhMajqoQbTQe2SK40 9idrT/rUjwXIQjHpmS8QvEg6+6w7k/07KJ18BpheWH+6DK++Z1cxr6EENLCvhWqDg/k9 5Lsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=qpUHw5LDqEWVEKrCEXmmGfbhnHn6idCG8Din3tEi/lc=; b=dwH5TiHc6kVzuKss0nU5d/JMl/gLCop8z5G3U9K1fR2iAh27Al9Lu3+vHBJPpOTOFq tKwQ8Zg5Z5bJf32zcJ5wd6ruw/LmPjU9ToPpkg25yo9ZoLv2kYqdN7dY/GQrm/fNatxz J7xm0IG4J8O3OjFr2+HIGdC9a5TNs9gH1F9lfrpl8OViYE/iLzHI4Qcc2Z04EtsOttYQ ZYbuCfJ0EN0ssRoP7vCJeIg7EjKBhtM+f2d5Ihm6y16rNnJ7TkmXgzw/6y+7vh8jDdaF qgBMargFulQXxfImDfHpojPr/ciuQNRy6EIoebugVIv0ZTlUodkxDk0rtZBDlSMYMxlg uPLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lls9FstW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a72-v6si362143pge.497.2018.08.06.21.19.44; Mon, 06 Aug 2018 21:20:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lls9FstW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731707AbeHGFfZ (ORCPT + 99 others); Tue, 7 Aug 2018 01:35:25 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:33043 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726913AbeHGFfZ (ORCPT ); Tue, 7 Aug 2018 01:35:25 -0400 Received: by mail-pl0-f65.google.com with SMTP id b90-v6so5699703plb.0 for ; Mon, 06 Aug 2018 20:23:12 -0700 (PDT) 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=qpUHw5LDqEWVEKrCEXmmGfbhnHn6idCG8Din3tEi/lc=; b=lls9FstWpHU4uRx3EAyL3w2LqmxlO3xJZPzB/bCwIMWQ2hF1bnFLHi49YC145ZbNTc yGmgOKc5ggtcwvc1donDGUItN6Xh4jJv7ZY4+dmRMpsYgxKOySkAy7FTvjIsXFcO4Zrm q8RQkXFqczEib9QHHBCxlQUB6DNt4On+8y9ztjOqcUrsKkkvMnLoxWHfQsqs2oZhNPXN L6t39MxbRIpV5BlgTuNrDKJLaqbnfQJsL0+hUZ3lfhmkT1ei0c+A2n4bZyl7eoKTl69b x7KZ+d0/PNw3KErSqToKg+ZjVo8+OMSry0jfmdtBObKnSf6i4ZeZxh47Vl+8dB4Gmeq3 7ubQ== 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=qpUHw5LDqEWVEKrCEXmmGfbhnHn6idCG8Din3tEi/lc=; b=pHknm5hNcp8Q1vY9sj91ZwsSQZlFhQ8MBsZMve8cTiJOZLu4vJ+7Ju8dI2sISAi2Gg LrMZ805tw6GQ8W2ATyXwO4BI0Gpt8uazMg5NRW8W1OO9Sc3e4pj9eftm1IMEJ6CsKt4j jzC+bYer035bijx4FpoVq2XdHzLdTaC0aKSktzlRMCxWphnUv5AJEUhT1OmQ8PfphX4P swSaERKHou2TCoErJGd6Dai2555QkYPXPC9DlzUBeLRkTnf6QD9TookyhYG1yZl37TGo 9JKMDnE0AR9pjA22tKl6ntFTNmzK5INXXruJ1rA7juiju4K9l3fB1JGFc5NnNDHhA+3u vEOg== X-Gm-Message-State: AOUpUlFTOb2CeruRHmj3ANyjp56R16HGZaRKaeMWtbKO89V9zmNFkLMB kJcxHX9XyeYyPSsiajbTDFTrIw== X-Received: by 2002:a17:902:4906:: with SMTP id u6-v6mr16170607pld.44.1533612191851; Mon, 06 Aug 2018 20:23:11 -0700 (PDT) Received: from [100.112.67.156] ([104.133.9.108]) by smtp.gmail.com with ESMTPSA id y86-v6sm234679pfk.84.2018.08.06.20.23.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Aug 2018 20:23:10 -0700 (PDT) Date: Mon, 6 Aug 2018 20:23:02 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: "zhaowuyun@wingtech.com" cc: Hugh Dickins , akpm , Michal Hocko , mgorman , minchan , vinmenon , hannes , "hillf.zj" , linux-mm , linux-kernel Subject: Re: Re: [PATCH] [PATCH] mm: disable preemption before swapcache_free In-Reply-To: <20180807101540612373235@wingtech.com> Message-ID: References: <2018072514375722198958@wingtech.com>, <20180725141643.6d9ba86a9698bc2580836618@linux-foundation.org>, <2018072610214038358990@wingtech.com>, <20180726060640.GQ28386@dhcp22.suse.cz>, <20180726150323057627100@wingtech.com>, <20180726151118.db0cf8016e79bed849e549f9@linux-foundation.org>, <20180727140749669129112@wingtech.com>, <20180807101540612373235@wingtech.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-1084447320-1533612190=:1570" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-1084447320-1533612190=:1570 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 7 Aug 2018, zhaowuyun@wingtech.com wrote: >=20 > Thanks for affirming the modification of disabling preemption and=20 > pointing out the incompleteness, delete_from_swap_cache() needs the same = protection. > I'm curious about that why don't put=C2=A0swapcache_free(swap) under prot= ection of=C2=A0mapping->tree_lock ?? That would violate the long-established lock ordering (see not-always- kept-up-to-date comments at the head of mm/rmap.c). In particular, swap_lock (and its more recent descendants, such as swap_info->lock) can be held with interrupts enabled, whereas taking tree_lock (later called i_pages lock) involves disabling interrupts. So: there would be quite a lot of modifications required to do swapcache_free(swap) under mapping->tree_lock. Generally easier would be to take tree_lock under swap lock: that fits the establishd lock ordering, and is already done in just a few places - or am I thinking of free_swap_and_cache() in the old days before find_get_page() did lockless lookup? But you didn't suggest that way, because it's more awkward in the __remove_mapping() case: I expect that could be worked around with an initial PageSwapCache check, taking swap locks there first (not inside swapcache_free()) - __remove_mapping()'s BUG_ON(!PageLocked) implies that won't be racy. But either way round, why? What would be the advantage in doing so? A more conventional nesting of locks, easier to describe and understand, yes. But from a performance point of view, thinking of lock contention, nothing but disadvantage. And don't forget the get_swap_page() end: there it would be harder to deal with both locks together (at least in the shmem case). Hugh --0-1084447320-1533612190=:1570--