From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757057AbcJXF3M (ORCPT ); Mon, 24 Oct 2016 01:29:12 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33072 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753488AbcJXF3J (ORCPT ); Mon, 24 Oct 2016 01:29:09 -0400 Date: Mon, 24 Oct 2016 14:29:05 +0900 From: Sergey Senozhatsky To: Minchan Kim Cc: Sergey Senozhatsky , Andrew Morton , Sergey Senozhatsky , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] zram: adjust the number of zram thread Message-ID: <20161024052905.GB1855@swordfish> References: <1474526565-6676-1-git-send-email-minchan@kernel.org> <1474526565-6676-3-git-send-email-minchan@kernel.org> <20161021062327.GC527@swordfish> <20161024045413.GC4938@blaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161024045413.GC4938@blaptop> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (10/24/16 13:54), Minchan Kim wrote: > > On (09/22/16 15:42), Minchan Kim wrote: > > [..] > > > +static int __zram_cpu_notifier(void *dummy, unsigned long action, > > > + unsigned long cpu) > > > { > > > struct zram_worker *worker; > > > > > > - while (!list_empty(&workers.worker_list)) { > > > + switch (action) { > > > + case CPU_UP_PREPARE: > > > + worker = kmalloc(sizeof(*worker), GFP_KERNEL); > > > + if (!worker) { > > > + pr_err("Can't allocate a worker\n"); > > > + return NOTIFY_BAD; > > > + } > > > + > > > + worker->task = kthread_run(zram_thread, NULL, "zramd-%lu", cpu); > > > + if (IS_ERR(worker->task)) { > > > + kfree(worker); > > > + pr_err("Can't allocate a zram thread\n"); > > > + return NOTIFY_BAD; > > > + } > > > > well, strictly speaking we are have no strict bound-to-cpu (per-cpu) > > requirement here, we just want to have num_online_cpus() worker threads. > > if we fail to create one more worker thread nothing really bad happens, > > so I think we better not block that cpu from coming online. > > iow, always 'return NOTIFY_OK'. > > If it doesn't make code complicated, I will do that in next spin. thanks. I think it won't. we don't really care how many workers we have, because the workers are not per-cpu. we just want to be as parallel as possible, but don't guarantee anything at all: who knows how those workers will be scheduled; may be we even can end up with just one active worker all the time, if other rq-s have higher prio tasks to run. there are many things that can be against us here. that's a massive complication of zram. preventing CPU from coming online is a bit over-reaction. -ss