Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933578AbdGKPiD (ORCPT ); Tue, 11 Jul 2017 11:38:03 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:9820 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933351AbdGKPiB (ORCPT ); Tue, 11 Jul 2017 11:38:01 -0400 Subject: Re: [PATCH v3 1/7] libsas: Use static sas event pool to appease sas event lost To: Yijing Wang , , References: <1499670369-44143-1-git-send-email-wangyijing@huawei.com> <1499670369-44143-2-git-send-email-wangyijing@huawei.com> CC: , , , , , , , , , , , , , , , , , , Johannes Thumshirn , Linuxarm From: John Garry Message-ID: Date: Tue, 11 Jul 2017 16:37:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1499670369-44143-2-git-send-email-wangyijing@huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.93.105] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.5964F0CE.01B7,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9f9c08a72bdb570c3c20fb7981529063 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2011 Lines: 53 On 10/07/2017 08:06, Yijing Wang wrote: > Now libsas hotplug work is static, every sas event type has its own > static work, LLDD driver queue the hotplug work into shost->work_q. > If LLDD driver burst post lots hotplug events to libsas, the hotplug > events may pending in the workqueue like > > shost->work_q > new work[PORTE_BYTES_DMAED] --> |[PHYE_LOSS_OF_SIGNAL][PORTE_BYTES_DMAED] -> processing > |<-------wait worker to process-------->| > In this case, a new PORTE_BYTES_DMAED event coming, libsas try to queue it > to shost->work_q, but this work is already pending, so it would be lost. > Finally, libsas delete the related sas port and sas devices, but LLDD driver > expect libsas add the sas port and devices(last sas event). > > This patch and use static sas event work pool to appease this issue, since > it's static work pool, it won't make memory exhaust. > [ ... ] > > +#define PORT_POOL_SIZE (PORT_NUM_EVENTS * 5) > +#define PHY_POOL_SIZE (PHY_NUM_EVENTS * 5) > + > /* The phy pretty much is controlled by the LLDD. > * The class only reads those fields. > */ > struct asd_sas_phy { > /* private: */ > - struct asd_sas_event port_events[PORT_NUM_EVENTS]; > - struct asd_sas_event phy_events[PHY_NUM_EVENTS]; > - > - unsigned long port_events_pending; > - unsigned long phy_events_pending; > + struct asd_sas_event port_events[PORT_POOL_SIZE]; > + struct asd_sas_event phy_events[PHY_POOL_SIZE]; > > int error; Hi Yijing, So now we are creating a static pool of events per PHY/port, instead of having 1 static work struct per event per PHY/port. So, for sure, this avoids the dynamic event issue of system memory exhaustion which we discussed in v1+v2 series. And it seems to possibly remove issue of losing SAS events. But how did you determine the pool size for a PHY/port? It would seem to be 5 * #phy events or #port events (which is also 5, I figure by coincidence). How does this deal with flutter of >25 events? Thanks, John