Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3479870ybl; Mon, 19 Aug 2019 20:00:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCqNjXo0s1dBlIGeZOdkJDkgtu3BJwBt6TFrWNFQ+GGt9lUQUeyTZYUryxrmPtVFD6AGZW X-Received: by 2002:a65:4786:: with SMTP id e6mr22199728pgs.448.1566270053139; Mon, 19 Aug 2019 20:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566270053; cv=none; d=google.com; s=arc-20160816; b=UVL6I0Cs2Ok2i6WJUvVLY8Bm/2xvLga17tHS8cyV9JMMFcVZjj06RrCiu43TU6omP8 zo/437zGDkOcmQZaHoOcRz/1oNDPaYlCBJi/2DzFGl8RQgpwkIdA0vbcF/sAalrCvJwL CMskLIalUYYtLSgU8ygD2BTp2W8BtIt85wYEep0//8yZpZaav4DWtew7yo7wq1L4RKzX 5yJsOCsQsJstOem7pVI7LMGI+qeICB8jUOfNehRpBDXIjDCtl6O+KceYQh7VQYDQjayM P4YYmaiakRDpflRG9mBsfOHsoy4knbUdnMRWSESbojM8rdNG0i+L5zbfMauMAbWm9NUp uchg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xkr4IFk7JE8tZJ5lH5GPaHBkXeIGAFFTk63OiHmuliw=; b=Npv37KbXRswb4qilcF1CPnL+NvsDvLZkl1ae5T3vYb/Ni016IqjgLE41nynSVUuDI6 z5KYWgh2C4DvwQ6fcIjuvf3umc/t3UuqyyWk6DRiZ/BthJXRyjM/1Tgu2RpBEwL0jAtK 3NTzDKee/FBP6KNE5nGeSVbtIrE2wgp8w8dq24hM3p+6GL1BBoH5kWwGvKPHDGHCBNYv E57zjPWBw7xIl0qXcEJ+prUzWvDu6fAjPQBaktQ+NhKMXx307SZSdQdFJFY7bSwt5diS OOsafd5YXlfjgW0doCHtoHQXUBS40mECneWJIWQS8WZGqCNWuNHpBULU1NcPfnL7wIHk EZoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LpB2kY8B; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f98si11135711plb.256.2019.08.19.20.00.37; Mon, 19 Aug 2019 20:00:53 -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=@gmail.com header.s=20161025 header.b=LpB2kY8B; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728898AbfHTC7o (ORCPT + 99 others); Mon, 19 Aug 2019 22:59:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40497 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728734AbfHTC7o (ORCPT ); Mon, 19 Aug 2019 22:59:44 -0400 Received: by mail-pf1-f193.google.com with SMTP id w16so2413342pfn.7 for ; Mon, 19 Aug 2019 19:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xkr4IFk7JE8tZJ5lH5GPaHBkXeIGAFFTk63OiHmuliw=; b=LpB2kY8BgQK2hpTo0dJctfeVuA/CaP6yYvy8cfnj76Y9sDqI2ujKQhZSHFyNdKgaOs En+s/YIUmXOpUpSzJTHQ7L9BYKYm1ICz6+j5v7Yn0Sdogcfa6s4eOsu2dqZSyHi45U8/ a2RqmxLh5nbeXuobqflCMc6jX2UZmlpRQSfEPkWYz1bxdpL+Vd9n1i+SWJmDrOfA2hEI YnBsyt0rW54mhn5WbD/lZVZ0XdHuH6p0TlbXosYL++PdLoHrkBIqIbwb8GEbE//u4zKw ZXuaOuvuhOqOD1yY2v9vrc8tZRW5SzcTdfGKrwhu8JYFRYVhYS54t9e6NnjDlB0kPyw2 4qMQ== 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:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xkr4IFk7JE8tZJ5lH5GPaHBkXeIGAFFTk63OiHmuliw=; b=pSNqiCHo9LeFINFgt8Y5349hGcVn1I5QMovPJwJCiov5uaCalZUl48+g7JW1lx7wpj olzCpnxdzsun8j3xC3YGEUWjKBil87aWY1enZwMfWGHc12ELHrSxWsVrhZl6+8C8IgPY pbR+99xWiVjt9fUZ3puoI8NhRy7vQac30lRsE3yzQlmRJ1clJN73++irYPUgk3wf6cUd pj57i+Aw0hdkpY0USWN36ts48bsFanoK3pj4tMlNDIpuPYtNPM26ErP2TGd2YggACOVE c584TizGfnV+Qf1VxN4uIRq6mZbbMJiyM+w8qFN8GfpWxlFj6Z4swHPSdIyon0sGPrYS 9F3g== X-Gm-Message-State: APjAAAXs+psj7jNUXrRyiwUW95YiCxPQawPDDk9Qt3DGggfJ7NDMKyOP AtVQrQ4LsyAQhjOLD+n3cPU= X-Received: by 2002:a62:38d7:: with SMTP id f206mr27847336pfa.102.1566269983701; Mon, 19 Aug 2019 19:59:43 -0700 (PDT) Received: from localhost ([175.223.16.125]) by smtp.gmail.com with ESMTPSA id a10sm21744430pfl.159.2019.08.19.19.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 19:59:42 -0700 (PDT) Date: Tue, 20 Aug 2019 11:59:39 +0900 From: Sergey Senozhatsky To: Henry Burns , Andrew Morton Cc: Minchan Kim , Nitin Gupta , Sergey Senozhatsky , Shakeel Butt , Jonathan Adams , HenryBurns , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2 v2] mm/zsmalloc.c: Fix race condition in zs_destroy_pool Message-ID: <20190820025939.GD500@jagdpanzerIV> References: <20190809181751.219326-1-henryburns@google.com> <20190809181751.219326-2-henryburns@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190809181751.219326-2-henryburns@google.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (08/09/19 11:17), Henry Burns wrote: > In zs_destroy_pool() we call flush_work(&pool->free_work). However, we > have no guarantee that migration isn't happening in the background > at that time. > > Since migration can't directly free pages, it relies on free_work > being scheduled to free the pages. But there's nothing preventing an > in-progress migrate from queuing the work *after* > zs_unregister_migration() has called flush_work(). Which would mean > pages still pointing at the inode when we free it. > > Since we know at destroy time all objects should be free, no new > migrations can come in (since zs_page_isolate() fails for fully-free > zspages). This means it is sufficient to track a "# isolated zspages" > count by class, and have the destroy logic ensure all such pages have > drained before proceeding. Keeping that state under the class > spinlock keeps the logic straightforward. > > Fixes: 48b4800a1c6a ("zsmalloc: page migration support") > Signed-off-by: Henry Burns Reviewed-by: Sergey Senozhatsky + Andrew -ss